Skip to content

useStopwatch ​

time
test coverage
Last changed: last month

Hook that creates a stopwatch functionality

typescript
import { useStopwatch } from '@siberiacancode/reactuse';

Usage ​

typescript
const { seconds, minutes, start, pause, reset } = useStopwatch(1000, { enabled: false });
// or
const { seconds, minutes, start, pause, reset } = useStopwatch({ initialTime: 1000, enabled: false });

Demo ​

Api ​

Parameters

NameTypeDefaultNote
initialTime?number0The initial time of the timer
options.enabled?booleantrueThe enabled state of the timer

Parameters

NameTypeDefaultNote
options.initialTime?number0-The initial time of the timer
options.enabled?booleantrueThe enabled state of the timer

Source ​

Source • Demo

Contributors ​

Avatardebabin
Avatarsereda

Released under the MIT License.