useStopwatch
A stopwatch with start, pause, reset and laps. Elapsed time comes from a monotonic clock, so the display can update at any rate and never loses time.
- Level
- Intermediate
- Since
- v2.1.0
import {useStopwatch} from '@zenuilabs/react-hooks';Loading demo_
More in Time & Motion
Time & MotionIntermediateuseAnimationFrameRun a callback on every animation frame with the time since the previous frame. Use it for canvas drawing, games and imperative animations where movement should be scaled by elapsed time.Time & MotionIntermediateuseCountdownCount down to a date or through a duration and expose days, hours, minutes and seconds. Time left is computed from the clock rather than by counting ticks, so it does not drift in background tabs. When the target is a Date, the first render depends on the current time, so render it on the client only to avoid a hydration mismatch.Time & MotionBasicuseIntervalRun a callback on a fixed interval that pauses when the delay is null. The latest callback is always called, so it can read fresh state without restarting the timer.