useTimeout
A hook that handles the setTimeout timer function.
Overview
A hook that handles the setTimeout timer function.
Installation
Open inpnpm dlx shadcn@latest add https://shadcn-ahooks.vercel.app/r/useTimeout.jsonnpx shadcn@latest add https://shadcn-ahooks.vercel.app/r/useTimeout.jsonyarn shadcn@latest add https://shadcn-ahooks.vercel.app/r/useTimeout.jsonbun shadcn@latest add https://shadcn-ahooks.vercel.app/r/useTimeout.jsonA hook that handles the setTimeout timer function.
Examples
Default usage
API
useTimeout(
fn: () => void,
delay?: number | undefined
): fn: () => void;Params
| Property | Description | Type |
| -- | -- |
| fn | The function to be executed after delay milliseconds. | () => void |
| delay | The number of milliseconds to wait before executing the function. The timer will be cancelled if delay is undefined. | number | undefined |
Result
| Property | Description | Type |
| | - | |
| clearTimeout | clear timeout | () => void |