mardi 29 janvier 2019

Multiple checkbox in react native

How do I make a multiple checkbox in the react native <CheckBox></CheckBox>?

Currently my checkbox is like this :

if(this.state.specialise_list != null){
  return this.state.specialise_list.map((data, i)=>(
    <View key={i} style=>
      <CheckBox
        containerStyle=
        value={this.state.specialise}
        onValueChange={(itemValue, itemKey) => this.setState({ specialise: itemValue })} />
      <Text style=> { data.name }</Text>
    </View>
  ))
}

My above code will check all the checkbox. I'm trying to insert the checked checkbox in an array in this form selected_specialise: [ '1', '2', '5', '24' ]; where the data will be removed from the array if the specific checkbox is unchecked.




Aucun commentaire:

Enregistrer un commentaire