I spotted three things which need to be corrected.
- The first mistake is a missing opening parenthesis within your
handleChange
event handler:
// You wrote:
setNewTask((prevState) => {
// It should be:
setNewTask((prevState) => ({
It has to do with implicit return of an object. See this post for why we need to wrap the curly braces in parentheses (the explanatory text of the “Objects in State” exercise also makes a brief mention of this). Your code does have the closing parenthesis though i.e. the line with }));
, so you are only missing the opening parenthesis.
- The second mistake is an extra closing parenthesis within your
handleSubmit
event handler:
// You wrote:
setAllTasks((prevState) => [newTask, ...prevState]));
// It should be:
setAllTasks((prevState) => [newTask, ...prevState]);
Here, we are doing an implicit return of an array. Since an array uses brackets [ ]
instead of curly braces { }
, so we can do an implicit return of the array without the need of parentheses.
- The third mistake is a missing opening parenthesis within your
handleDelete
event handler:
// You wrote:
setAllTasks((prevState) => prevState.filter(task) => task.id !== taskIDtoRemove));
// It should be:
setAllTasks((prevState) => prevState.filter((task) => task.id !== taskIDtoRemove));
You are missing an opening parenthesis after filter
. You do have the closing parenthesis though, so you only need to insert the opening parenthesis.