useInterval
Sets up an interval with imperative controls. Returns start/stop methods and running state.
useInterval
Installation
Usage
API
useInterval
Sets up an interval with imperative controls. Returns start/stop methods and running state.
Parameters
Name | Type | Description |
---|---|---|
callback | () => void | Function to execute at each interval tick (automatically uses latest version) |
delay | number | null | Interval delay in milliseconds (null to clear interval) |
options | IntervalOptions | Optional configuration for the interval |
immediate | boolean | If true, the callback function will be executed immediately after the interval starts (default: false) |
autoStart | boolean | If true, the interval will start automatically (default: true) |
Returns
Name | Type | Description |
---|---|---|
start | void | |
stop | void | |
toggle | void | |
isRunning | boolean |