Description

A stopwatch counts up every second and can be reset to zero with a button.

Anomaly

Click Reset once - the counter ticks normally but jumps by 2 every second. Click again - jumps by 3. The interval stacks with each reset.

Constraint
Do not change the interval duration or the tick logic
Hint
Consult the SenseiOnly for those truly stuck · Flip to reveal

What happens to the previous interval when the effect runs again?

Loading editor…
Correct Solution
Loading...

Why this fixes it

The effect started a new `setInterval` every time `running` flipped back to `true` but returned nothing, so React had no cleanup instruction and left every previous interval running alongside the new one - each Reset call added another tick to the pile. Adding `return () => clearInterval(id)` gives React a teardown function it calls before re-running the effect, which cancels the old interval before a new one is registered.

Expected OutputGoal State
Your OutputLive