Training Grounds
Array Push Freezes the ListWhite Belt
+10 Ki
Description

A task list lets the user type a task name and add it to the list by clicking Add. The list always wipes itself empty on every Add click — no task ever stays in the list. React compares state by reference, so passing a new array is required to trigger a re-render with the correct contents.

Anomaly

Type any task name, click Add — the input clears but the list stays empty every single time. No tasks ever accumulate.

Constraint
Fix must create a new array instead of mutating the existing one
Do not replace useState with useReducer
Hint

Think about what value you are passing to setTasks — is it a new array, or is it wiping the old one?

Consult the SenseiOnly for those truly stuck · Flip to reveal

Think about what value you are passing to setTasks — is it a new array, or is it wiping the old one?

Loading editor…
Correct Solution
Loading...
Expected OutputGoal State
Your OutputLive