Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumReactuseEffect dependency arraysSingle-choice MCQ

This effect sets up an interval that reads `count`, but the displayed count freezes at 1 after the first tick even though the timer keeps firing. Why?

function Ticker() { const [count, setCount] = useState(0); useEffect(() => { const id = setInterval(() => setCount(count + 1), 1000); return () => clearInterval(id); }, []); return <span>{count}</span>; }