useDebounceEffect
Debounce your useEffect.
Overview
Debounce your useEffect.
Installation
Open inpnpm dlx shadcn@latest add https://shadcn-ahooks.vercel.app/r/useDebounceEffect.jsonnpx shadcn@latest add https://shadcn-ahooks.vercel.app/r/useDebounceEffect.jsonyarn shadcn@latest add https://shadcn-ahooks.vercel.app/r/useDebounceEffect.jsonbun shadcn@latest add https://shadcn-ahooks.vercel.app/r/useDebounceEffect.jsonDebounce your useEffect.
Examples
Default usage
API
useDebounceEffect(
effect: EffectCallback,
deps?: DependencyList,
options?: Options
);Params
| Property | Description | Type | Default |
| -- | - | - |
| effect | The effect callback. | EffectCallback | - |
| deps | The dependencies list. | DependencyList | - |
| options | Config for the debounce behaviors. See the Options section below for details. | Options | - |
Options
| Property | Description | Type | Default |
| -- | - | ---- |
| wait | The number of milliseconds to wait. | 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 | - |