Frontend Mission · React
Mission #003: The Stale Closure Timer Bug
Difficulty: Mid–SeniorEstimated time: 5 minutes
Skills
React HooksClosuresuseEffectStateProduction Debugging
Scenario
A timer created inside useEffect keeps reading the initial state value even though the UI shows that the state has changed.
Your task is to explain why and choose a correct way to read changing state.