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

A `useCallback` with empty deps is passed to a child. Why does calling it later operate on stale props, and which fix avoids the stale closure WITHOUT re-creating the callback on every render?

function Search({ query }) { const run = useCallback(() => { fetch(`/s?q=${query}`); }, []); // query omitted return <Child onRun={run} />; }