mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-03-27 22:55:56 +08:00
Implements the CheckBox component and adds a web-only 'color' prop to allow the color of the checkbox to be customized.
60 lines
1.6 KiB
JavaScript
Executable File
60 lines
1.6 KiB
JavaScript
Executable File
/**
|
|
* @flow
|
|
*/
|
|
|
|
import styles from './styles';
|
|
import React, { PureComponent } from 'react';
|
|
import { CheckBox, Text, View } from 'react-native';
|
|
|
|
class CheckBoxOnValueChangeExample extends PureComponent {
|
|
state = {
|
|
eventSwitchIsOn: false,
|
|
eventSwitchRegressionIsOn: true
|
|
};
|
|
|
|
render() {
|
|
const { eventSwitchIsOn, eventSwitchRegressionIsOn } = this.state;
|
|
|
|
return (
|
|
<View style={styles.row}>
|
|
<View style={[styles.alignCenter, styles.marginRight]}>
|
|
<CheckBox
|
|
onValueChange={this._handleEventSwitch}
|
|
style={styles.marginBottom}
|
|
value={eventSwitchIsOn}
|
|
/>
|
|
<CheckBox
|
|
onValueChange={this._handleEventSwitch}
|
|
style={styles.marginBottom}
|
|
value={eventSwitchIsOn}
|
|
/>
|
|
<Text>{eventSwitchIsOn ? 'On' : 'Off'}</Text>
|
|
</View>
|
|
<View style={styles.alignCenter}>
|
|
<CheckBox
|
|
onValueChange={this._handleEventSwitchRegression}
|
|
style={styles.marginBottom}
|
|
value={eventSwitchRegressionIsOn}
|
|
/>
|
|
<CheckBox
|
|
onValueChange={this._handleEventSwitchRegression}
|
|
style={styles.marginBottom}
|
|
value={eventSwitchRegressionIsOn}
|
|
/>
|
|
<Text>{eventSwitchRegressionIsOn ? 'On' : 'Off'}</Text>
|
|
</View>
|
|
</View>
|
|
);
|
|
}
|
|
|
|
_handleEventSwitch = value => {
|
|
this.setState({ eventSwitchIsOn: value });
|
|
};
|
|
|
|
_handleEventSwitchRegression = value => {
|
|
this.setState({ eventSwitchRegressionIsOn: value });
|
|
};
|
|
}
|
|
|
|
export default CheckBoxOnValueChangeExample;
|