lundi 2 juillet 2018

How to create checkbox with different values when mapping in React Native?

I am getting an array from another screen with getParam and mapping it

But in this case when I click on Checkbox, values of all checboxes is true or false

How I need to solve this problem?

I think it should be related with keys, but I can't create properly state

state = {
   checked: false,
}


{this.props.navigation.getParam('friends').map((val, key) => (
        <View>
          <Text style=>{val}</Text>
          <CheckBox
            checked={this.state.checked}
            onPress={() => this.setState({ checked: !this.state.checked })}
          />
        </View>
      ))}




Aucun commentaire:

Enregistrer un commentaire