useInterval
Custom hook that creates an interval that invokes a callback function at a specified delay using the [
setInterval API](https://developer.Installation
npx sse-tool add use-interval
npm install sse-hooks
Usage
import { useInterval } from "./{hooks file}";
const handleInterval = () => {
// Code to be executed at each interval
};
useInterval(handleInterval, 1000);
import { useInterval } from "sse-hooks";
const handleInterval = () => {
// Code to be executed at each interval
};
useInterval(handleInterval, 1000);
API
Parameters
| Name | Type | Description |
| :------- | :--------- | :------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| callback | Function | The function to be invoked at each interval. |
| delay | number | any | The time, in milliseconds, between each invocation of the callback. Use null to clear the interval. |