shadcn-ahooks

useDebounceEffect

Debounce your useEffect.

Overview

Debounce your useEffect.

Documentation and Examples

Installation

Open in
pnpm dlx shadcn@latest add https://shadcn-ahooks.vercel.app/r/useDebounceEffect.json
npx shadcn@latest add https://shadcn-ahooks.vercel.app/r/useDebounceEffect.json
yarn shadcn@latest add https://shadcn-ahooks.vercel.app/r/useDebounceEffect.json
bun shadcn@latest add https://shadcn-ahooks.vercel.app/r/useDebounceEffect.json

Debounce 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 | - |

On this page