Per Second Timer
Watch the walkthrough
Open on InstagramExercise: Build a start/stop timer
Display elapsed time starting at zero, with Start, Stop, and Reset controls. Update the display once per second while running. Stop pauses without losing the elapsed value; Start resumes; Reset returns to zero and stops.
Requirements
- Create at most one interval and clear it on stop, reset, and unmount.
- Use state updaters or an elapsed-time model that avoids a stale callback closure.
- Define disabled states so repeatedly pressing Start never doubles the ticking rate.
- Format minutes and seconds consistently; derive elapsed time from a clock when accuracy matters.
Acceptance checks and discussion
Start twice, pause for several seconds, resume, reset while running, and unmount. Explain that timer callbacks can be delayed, so counting callbacks is a simple demonstration rather than an accurate clock.
The brief above is an original practice specification. The linked sandbox is supporting solution material and may implement a simpler subset of these requirements.