shadcn-ahooks

useThrottle

A hook that deal with the throttled value.

Overview

A hook that deal with the throttled value.

Documentation and Examples

Installation

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

A hook that deal with the throttled value.

Examples

Default usage

API

const throttledValue = useThrottle(
  value: any,
  options?: Options
);

Params

| Property | Description | Type | Default | | -- | | - | | value | The value to throttle. | any | - | | options | Config for the throttle behaviors. | Options | - |

Options

| Property | Description | Type | Default | | -- | | - | | wait | The number of milliseconds to delay. | 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