Size
0.72 kb
useCountdown
Countdown utility based on useInterval.
Installation
Usage
Get the remaining milliseconds:
Transform the remaining time in seconds:
Use a custom interval between each tick:
Prevent rerendering the component on every tick:
Synchronize all countdowns using the same interval:
Add more details on the current countdown state:
API Reference
UseCountdownOptions
The options of the `useCountdown` hook.
Prop | Type | Default |
---|---|---|
sync? | boolean | false |
trackState? | boolean | true |
onExpire? | (() => void) | - |
onTick? | ((value: T) => void) | - |
transform? | ((ms: number, to: To) => T) | - |
interval? | number | 1000 |
to | Date | string | null | undefined | false | - |