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

PropertyDescriptionTypeDefault
valueThe value to throttle.any-
optionsConfig for the throttle behaviors.Options-

Options

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

On this page