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

This component logs a value on an interval. The developer 'fixed' the classic stale-closure interval by adding `count` to the effect deps. What new behavior does this introduce at the runtime level, and is the logged value now correct?

function Ticker() { const [count, setCount] = useState(0); useEffect(() => { const id = setInterval(() => console.log(count), 1000); return () => clearInterval(id); }, [count]); return <button onClick={() => setCount(c => c + 1)}>{count}</button>; }