I have a delete button on a todo list, and the splice isn't working properly. I get the id of the button and simply want to delete that item.
<ul>
{this.state.tasks.map((task, i) =>
<li key={i}>
{task}
<button id={i} onClick={this.removeTask}>Delete</button>
</li>
)}
</ul>
removeTask = (event) => {
// console.log(event.target.id);
const index = parseInt(event.target.id);
console.log(index);
this.setState(state => ({
tasks: [...state.tasks].splice(index,1),
count: state.count - 1,
}))
}