useInterval
Custom hook that creates an interval that invokes a callback function at a specified delay using the [`setInterval API`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval).
Custom hook that creates an interval that invokes a callback function at a specified delay using the setInterval API.
Usage
import { useInterval } from "@tilt-legal/cubitt-components/utilities/hooks";
const handleInterval = () => {
// Code to be executed at each interval
};
useInterval(handleInterval, 1000);API
Signature
declare function useInterval(callback: () => void, delay: number | null): void;Parameters
| Parameter | Type | Description | Default |
|---|---|---|---|
callback | () => void | The function to be invoked at each interval. | - |
delay | `number | null` | The time, in milliseconds, between each invocation of the callback. Use null to clear the interval. |
Return Value
| Value | Type | Description |
|---|---|---|
return | void | Value returned by the hook. |