Loading…
A short voice session: one question, one follow-up, then instant feedback — up to 5 minutes.
The interval callback captured count from the first render and never sees later values; use the updater form of the setter, or include count in dependencies and recreate the interval.
Each render creates new functions that close over that render's values. With [] the effect runs once, so the interval callback keeps the count from the first render forever. If the callback only needs to update state, use setCount(c => c + 1), which reads the latest value without depending on count. If it must read current values, add them to the dependency array so the effect cleans up the old interval and creates a new one. Another option is storing the latest value or callback in a ref that the interval reads.