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

| Property | Description | Type | Default | | -- | | -- | ---- | | wait | The number of milliseconds to wait. | number | 1000 | | leading | Specify invoking on the leading edge of the timeout. | boolean | true | | trailing | Specify invoking on the trailing edge of the timeout. | boolean | true |

On this page