Description

A name filter uses useMemo to recompute only when the search query changes. A separate counter button is unrelated to the filter.

Anomaly

Click the counter button — the filter run count goes up even though the search query never changed. The memo is recomputing when it shouldn't.

Constraint
Do not remove useMemo
Do not remove the counter button
Hint
Consult the SenseiOnly for those truly stuck · Flip to reveal

useMemo recomputes whenever any value in its dependency array changes — are all listed dependencies actually used inside it?

Loading editor…
Correct Solution
Loading...

Why this fixes it

count was listed in the dependency array but is never read inside the useMemo callback — only query is used. Every button click updated count, which invalidated the memo and triggered an unnecessary recompute. Removing count from the dependency array means the memo only reruns when query actually changes, which is the only value the filter depends on.

Expected OutputGoal State
Your OutputLive