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

PropertyDescriptionTypeDefault
effectThe effect callback.EffectCallback-
depsThe dependencies list.DependencyList-
optionsConfig for the debounce behaviors. See the Options section below for details.Options-

Options

PropertyDescriptionTypeDefault
waitThe number of milliseconds to wait.number1000
leadingSpecify invoking on the leading edge of the timeout.booleanfalse
trailingSpecify invoking on the trailing edge of the timeout.booleantrue
maxWaitThe maximum time func is allowed to be delayed before it’s invoked.number-

On this page