Training Grounds
List Ignores Everything You TypeBlue Belt
+25 Ki
Description

A search box filters a list of items, showing only those that match what the user types.

Anomaly

Type any letter into the search box - the list stays frozen at the full unfiltered set every time. The input updates but the results never react.

Constraint
Do not replace `useMemo` with inline computation or `useEffect`
Do not remove useMemo
Hint

When does `useMemo` decide to recompute?

Consult the SenseiOnly for those truly stuck · Flip to reveal

When does `useMemo` decide to recompute?

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

Why this fixes it

`useMemo` with an empty dependency array computed the filtered list once on mount and cached it permanently - because `query` was not listed as a dependency, React never knew to invalidate the memo, so the full unfiltered list was returned on every subsequent render. Adding `query` to the dependency array tells React to recompute the memoized value whenever `query` changes.

Expected OutputGoal State
Your OutputLive