I'm working on a To Do application and when I check one box off and delete it the next in the list gets mark completed. I'm not sure what's going wrong
Tried using splice and filter, at first I thought it was because splice was using the index but I switched to using filter and have the same problem.
```react
function ToDoList() {
const [toDos, setToDos] = useState([
{id: uuid(), toDo: "Workout", done: false},
{id: uuid(), toDo: "Grocery shopping", done: false},
{id: uuid(), toDo: "Cook dinner", done: false},
{id: uuid(), toDo: "Walk dog", done: false},
{id: uuid(), toDo: "Do laundry", done: false},
])
// const removeToDo = index => {
// const newToDos = [...toDos];
// newToDos.splice(index, 1);
// setToDos(newToDos);
// }
```switched to filter
const removeToDo = toDoId => {
const newToDos = toDos.filter(toDo => toDo.id !== toDoId);
setToDos(newToDos);
}
return (
<StyledToDoList>
<div className="ToDoContainer">
<header className="ToDoHeader">To-Do List</header>
<ToDoForm addToDo={addToDo} />
<ul className="ToDoList">
{toDos.map((toDo, index) => (
<ToDo
id={toDo.id}
toDo={toDo}
index={index}
key={`${toDoInfo.id}${index}`}
removeToDo={removeToDo}
/>
))}
</ul>
<RemoveChecked />
</div>
</StyledToDoList>
)
}
function ToDo({ toDo, removeToDo }) {
const [value, setValue] = useState(false)
return (
<StyledToDo>
<li className="ToDoWrapper">
<Checkbox
id={toDo.id}
isOn={value}
handleToggle={() => setValue(!value)}
/>
<span className="ToDoItem">{toDo.toDo}</span>
<button className="ToDoButton" type="button" onClick={() => removeToDo(toDo.id)}>
×
</button>
</li>
</StyledToDo>
)
}
Expected after deleting checked list item, the next one remains unchecked, but it marks the next one complete.