I'm implementing a To-Do list in React Native, but for some reason after I remove a task, the next task in the array takes some values of the one I removed. I made a copy of the state array and made changes to it, console.log them to see that everything was right, then setState with that copy. I think it must be an issue with the sate. Here is simplified version of my remove_task function. Am I doing something wrong?
_removeTask = (tindex) => {
/*removes a task in the tasks array*/
//make copy of state array
var tasks = [...this.state.Tasks];
var taskCount = 0;
tasks.splice(tIndex, 1);
//update the index of every quest
tasks.forEach(
(value, index) => {
value.tIndex = index;
value.selected = false;
value.isActiveDummyTask = false;
value.isInEditMode = false;
taskCount++;
}
)
this.setState({
Tasks: tasks,
TCount: taskCount,
});
}