Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardReactstale-closure pitfallsSingle-choice MCQ

A `useMemo` produces a callback that closes over `query`. The deps array is `[debouncedQuery]` (a debounced copy), not `[query]`. The intent is to rebuild the callback only when the debounced value settles. What stale-value bug does this create?

const run = useMemo(() => { return () => fetchResults(query); // reads live `query` }, [debouncedQuery]);