Open
Description
For the solution to the third challenge in the Updating Arrays in State page, it uses the following function:
function handleAddTodo(title) {
setTodos([
...todos,
{
id: nextId++,
title: title,
done: false
}
]);
}
This changes nextId
, a variable outside the component's scope, which I believe is a mutation. It should instead use the length of todos
to set the next id.