useInterval
A hook that handles the setInterval timer function.
Overview
A hook that handles the setInterval timer function.
Installation
Open inpnpm dlx shadcn@latest add https://shadcn-ahooks.vercel.app/r/useInterval.jsonnpx shadcn@latest add https://shadcn-ahooks.vercel.app/r/useInterval.jsonyarn shadcn@latest add https://shadcn-ahooks.vercel.app/r/useInterval.jsonbun shadcn@latest add https://shadcn-ahooks.vercel.app/r/useInterval.jsonA hook that handles the setInterval timer function.
Examples
Default usage
Advanced usage
API
useInterval(
fn: () => void,
delay?: number | undefined,
options?: Options
): fn: () => void;Params
| Property | Description | Type |
| -- | - | | | - |
| immediate | Whether the function should be executed immediately on first execution | boolean | false |
Result
| Property | Description | Type |
| - | -- | |
| clearInterval | clear interval | () => void |