useInterval
A hook that creates an interval.
Loading...
Installation
npx shadcn@latest add @shadcnhooks/use-intervalAPI
/**
* A hook that creates an interval.
* @param fn - The function to execute repeatedly
* @param delay - The delay in milliseconds between each execution. Set to null to pause the interval
* @param options - The options for the interval
* @param options.immediate - Whether to execute the function immediately
* @default { immediate: false } if not provided
* @returns A function to clear the interval
*/
export function useInterval(
fn: () => void,
delay: number | null = null,
options?: { immediate?: boolean },
): () => voidCredits
Last updated on