/**
* Copyright (c) 2017-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @providesModule CheckBoxExample
* @format
*/
'use strict';
const React = require('react');
const ReactNative = require('react-native');
const {CheckBox, Text, View} = ReactNative;
class BasicCheckBoxExample extends React.Component<{}, $FlowFixMeState> {
state = {
trueCheckBoxIsOn: true,
falseCheckBoxIsOn: false,
};
render() {
return (
this.setState({falseCheckBoxIsOn: value})}
style={{marginBottom: 10}}
value={this.state.falseCheckBoxIsOn}
/>
this.setState({trueCheckBoxIsOn: value})}
value={this.state.trueCheckBoxIsOn}
/>
);
}
}
class DisabledCheckBoxExample extends React.Component<{}, $FlowFixMeState> {
render() {
return (
);
}
}
class EventCheckBoxExample extends React.Component<{}, $FlowFixMeState> {
state = {
eventCheckBoxIsOn: false,
eventCheckBoxRegressionIsOn: true,
};
render() {
return (
this.setState({eventCheckBoxIsOn: value})}
style={{marginBottom: 10}}
value={this.state.eventCheckBoxIsOn}
/>
this.setState({eventCheckBoxIsOn: value})}
style={{marginBottom: 10}}
value={this.state.eventCheckBoxIsOn}
/>
{this.state.eventCheckBoxIsOn ? 'On' : 'Off'}
this.setState({eventCheckBoxRegressionIsOn: value})
}
style={{marginBottom: 10}}
value={this.state.eventCheckBoxRegressionIsOn}
/>
this.setState({eventCheckBoxRegressionIsOn: value})
}
style={{marginBottom: 10}}
value={this.state.eventCheckBoxRegressionIsOn}
/>
{this.state.eventCheckBoxRegressionIsOn ? 'On' : 'Off'}
);
}
}
let examples = [
{
title: 'CheckBoxes can be set to true or false',
render(): React.Element {
return ;
},
},
{
title: 'CheckBoxes can be disabled',
render(): React.Element {
return ;
},
},
{
title: 'Change events can be detected',
render(): React.Element {
return ;
},
},
{
title: 'CheckBoxes are controlled components',
render(): React.Element {
return ;
},
},
];
exports.title = '';
exports.displayName = 'CheckBoxExample';
exports.description = 'Native boolean input';
exports.examples = examples;