useTimeout
A hook that handles the setTimeout
timer function.
Examples
Default usage
1
Basic usage
Execute once after 3000ms
count:1
Delay:1000
Advanced usage
Modify the delay to realize the timer timeout change and pause.
API
useTimeout( fn: () => void, delay?: number | (() => number | undefined) | Accessor<number | undefined>): fn: () => void;
useTimeout( fn: () => void, delay?: number | (() => number | undefined) | Accessor<number | undefined>): fn: () => void;
Params
Property | Description | Type |
---|---|---|
fn | The function to be executed after delay milliseconds. | () => void |
delay | The number of milliseconds to wait before executing the function. The timer will be cancelled if delay is undefined . | number | (() => number | undefined) | Accessor<number | undefined> |
Result
Property | Description | Type |
---|---|---|
clearTimeout | clear timeout | () => void |