I'm using react-native-elements checkbox, i have 2 checkboxes and i want to select one of them only and i managed to do that, but I'm trying to console.log the checked box only but it's not working because they have two different states, so how can i determine which box was checked in my app using the state? here is the code:
Initial state:
state: {
single: false,
married: false
}
Checkboxes:
<CheckBox title="Single"
checked={this.state.single}
onPress={() => this.setState({ single: !this.state.single,
married: false})}/>
<CheckBox title="Married"
checked={this.state.married}
onPress={() => this.setState({ married: !this.state.married,
single: false})}/>
Aucun commentaire:
Enregistrer un commentaire