I am making a list of check boxes but when I press on one checkbox, it checks all of the checkboxes. I want to select one at a time.
I tried the sample code from react-native-elements 1.1.0 documentation as well as examples from other people but I cannot find the solution.
constructor() {
super();
this.state = {
checked: false,
};
}
render() {
return (
<View style={styles.container}>
<ScrollView>
<CheckBox
checkedIcon='dot-circle-o'
uncheckedIcon='circle-o'
title='checkbox 1'
checkedColor='red'
checked={this.state.checked}
onPress={() => this.setState({ checked: !this.state.checked })}
/>
<CheckBox
checkedIcon='dot-circle-o'
uncheckedIcon='circle-o'
title='checkbox 2'
checkedColor='red'
checked={this.state.checked}
onPress={() => this.setState({ checked: !this.state.checked })}
/>
</ScrollView>
</View>
);
}
}
I want to select one checkbox at a time (select the checkbox that I pressed on instead of selecting all at once).
Aucun commentaire:
Enregistrer un commentaire