I have problem with removeItem function (it should remove current that button is nested in, and item from array on this.state.list), no code currentl
removeItem(item) {
const item = getItem(this.state.list, item.id) // Method to get item in list through comparison (IE: find some item with item.id), it has to return ITEM and INDEX in array
const newlist = [].concat(list) // Clone array with concat or slice(0)
newlist.splice(item.index, 1);
this.setState({list: newlist});
}
_deleteTodo(index) {
console.log("delete " + index);
this.state.todos.splice(index, 1);
this.setState({
todos: this.state.todos.filter(i => i !== index)
});
}
I had a problem with splice and i honestly don know why. However this method work for me and you can try it! Ps. If anybody know why splice is not working with state and index please let me know i am curious!