Loading lesson…
Level 1 · Apprentice0 XP
Running code that touches the world outside React, and cleaning up after it.
Step 1 / 5
ProblemA component starts a timer when it appears. The user leaves the screen. The timer keeps firing and tries to update a component that is gone. After a few visits there are ten timers.
← → step
Before this: Derive state, do not sync it
🛠️ Your turn
Reading is not the skill, doing is. Try for ten minutes before you open the hint. Getting stuck first is what makes the solution stick.
1.Write a component that shows the window width and updates on resize, with cleanup. Then write a clock that ticks every second, and check with a console.log that only one interval exists after you show and hide it five times.