Shadcn Hooks

useTimeout

A hook that creates a timeout.

Loading...

Installation

npx shadcn@latest add @shadcnhooks/use-timeout

API

/**
 * A hook that creates a timeout.
 * @param fn - The function to execute after the timeout
 * @param delay - The delay in milliseconds before the function is executed
 * @returns A function to clear the timeout
 */
export function useTimeout(fn: () => void, delay: number = 0): () => void

Credits

Last updated on

On this page