Skip to content

useStopwatch ​

Hook that creates a stopwatch functionality

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

Usage ​

typescript
const { seconds, minutes, start, pause, reset } = useStopwatch(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

Contributors ​

Source • Demo