Skip to content

useInterval ​

Category
Time

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

NameTypeDefaultNote
callback() => void-Any callback function
interval?number1000Time in milliseconds
options.immediate?booleantrueStart the interval immediately

Parameters

NameTypeDefaultNote
callback() => void-Any callback function
options.interval?number1000Time in milliseconds
options.immediate?booleantrueStart the interval immediately

Contributors ​

Source • Demo