useDebounce
A hook that deal with the debounced value.
Overview
A hook that deal with the debounced value.
Installation
Open inpnpm dlx shadcn@latest add https://shadcn-ahooks.vercel.app/r/useDebounce.jsonnpx shadcn@latest add https://shadcn-ahooks.vercel.app/r/useDebounce.jsonyarn shadcn@latest add https://shadcn-ahooks.vercel.app/r/useDebounce.jsonbun shadcn@latest add https://shadcn-ahooks.vercel.app/r/useDebounce.jsonA hook that deal with the debounced value.
Examples
Default usage
API
const debouncedValue = useDebounce(
value: any,
options?: Options
);Params
| Property | Description | Type | Default |
| -- | | - |
| value | The value to debounce. | any | - |
| options | Config for the debounce behaviors. | Options | - |
Options
| Property | Description | Type | Default |
| -- | - | ---- |
| wait | The number of milliseconds to delay. | number | 1000 |
| leading | Specify invoking on the leading edge of the timeout. | boolean | false |
| trailing | Specify invoking on the trailing edge of the timeout. | boolean | true |
| maxWait | The maximum time func is allowed to be delayed before it’s invoked. | number | - |