Training Grounds
Search Box Has No EffectWhite Belt
+10 Ki
Description

A search box filters a list of items, showing only those that match the current query.

Anomaly

Type any character into the search box - the list does not update. All six items remain visible regardless of what you type. The input field updates correctly but the results list is permanently frozen at the initial unfiltered state.

Constraint
Do not replace useEffect with inline filtering
Hint

The effect runs - but ask yourself when it runs.

Consult the SenseiOnly for those truly stuck · Flip to reveal

The effect runs - but ask yourself when it runs.

Practice 41 related drills →
Loading editor…
Correct Solution
Loading...

Why this fixes it

The effect closed over `query` at the time it was first created - with an empty dependency array, React never re-ran it, so the filter logic permanently operated on the empty string captured at mount. Adding `query` to the dependency array tells React to re-execute the effect whenever `query` changes, so the closure always captures the current search string.

Expected OutputGoal State
Your OutputLive