I am trying to implement checked and unchecked box in a flatlist.
I have taken a keyword checked. On the basis of this keyword I want to show the checkbox (checked or unchecked)
I am trying to update the checked key on selection and deselection.
But getting errors.
Can anyone tell me what is wrong here?
Here is my code:
updateItem(item) {
this.setState({
array : ! this.array.findIndex(item => item.title === item.title).checked
})
this.setState({ array: [...this.array] });
}
My array is:
(this.array = [{title: "Option 1",checked:"false"},
{ title: "Option 2" ,checked:"false"},
{ title: "Option 3",checked:"false"},
{ title: "Option 4",checked:"false" },
{ title: "Option 5",checked:"false"}
])
Thanks!
Aucun commentaire:
Enregistrer un commentaire