Description

A memoized log button captures a message from an input and logs it to a display. After typing a new message and clicking Log, the old message appears instead of the new one.

Anomaly

Type a message and click Log — an empty entry appears in the list. Type another message and click Log again — another empty entry. The log fills with blank items instead of the typed messages.

Constraint
Fix only the useCallback dependency array
Do not remove useCallback
Hint
Consult the SenseiOnly for those truly stuck · Flip to reveal

useCallback memoizes the function and only recreates it when dependencies change. If message is not in the dependency array, the callback always closes over the initial empty string.

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