I have a list of items in my React Native App.
Initially the item's "id" is stored in an array of objects.
Each time i click an item the item's id is removed form the array. Code for id removal:
let found = this.state.genList.find((a) => a.id === item.id);
let index = this.state.genList.indexOf(found);
if (index > -1) {
this.state.genList.splice(index, 1);
}
AsyncStorage.setItem('general_messages', this.state.genList);
Using splice I remove an element with the help of it's index.
This works only ONCE.
The next time I click an item I get the below error.
Why is "splice" causing this issue??
How else could I have written this??
Please help!!