useInterval ​
Hook that makes and interval and returns controlling functions
typescript
import { useInterval } from '@siberiacancode/reactuse';
Usage ​
typescript
const { active, pause, resume } = useInterval(() => console.log('inside interval'), 2500);
Demo ​
Api ​
Parameters
Name | Type | Default | Note |
---|---|---|---|
callback | () => void | - | Any callback function |
interval? | number | 1000 | Time in milliseconds |
options.immediate? | boolean | true | Start the interval immediately |
Returns
Parameters
Name | Type | Default | Note |
---|---|---|---|
callback | () => void | - | Any callback function |
options.interval? | number | 1000 | Time in milliseconds |
options.immediate? | boolean | true | Start the interval immediately |