Training Grounds
useEffect Missing DependencyWhite Belt
+10 Ki
Description

A search box filters a list. Typing a new query should update the results. After the first keystroke the results never change again

Anomaly

Type one character — the list filters correctly. Type a second character — the list does not update. The results are frozen after the first change.

Constraint
Fix only the useEffect dependency array
Do not move the filter logic outside the effect
Hint

The effect that runs the filter captures the query value at the time it was created. If query is not in the dependency array, the effect never re-runs when query changes.

Consult the SenseiOnly for those truly stuck · Flip to reveal

The effect that runs the filter captures the query value at the time it was created. If query is not in the dependency array, the effect never re-runs when query changes.

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