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.
Type any task name, click Add - the input clears but the list stays empty every single time. No tasks ever accumulate.
Look closely at what setTasks is being called with.
Look closely at what setTasks is being called with.
Why this fixes it
`tasks.push(input)` mutated the existing array then `setTasks([])` discarded it entirely, resetting the list to empty on every add. Replacing both lines with `setTasks([...tasks, input])` creates a new array containing all previous items plus the new one, which React detects as a state change and re-renders with the accumulated list.