shadcn-ahooks

useThrottleEffect

Throttle your useEffect.

Overview

Throttle your useEffect.

Documentation and Examples

Installation

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

Throttle your useEffect.

Examples

Default usage

API

useThrottleEffect(
  effect: EffectCallback,
  deps?: DependencyList,
  options?: Options
);

Params

PropertyDescriptionTypeDefault
effectThe effect callback.EffectCallback-
depsThe dependencies list.DependencyList-
optionsConfig the throttle behavior. See the Options section below.Options-

Options

PropertyDescriptionTypeDefault
waitThe number of milliseconds to wait.number1000
leadingSpecify invoking on the leading edge of the timeout.booleantrue
trailingSpecify invoking on the trailing edge of the timeout.booleantrue

On this page