shadcn-ahooks

useThrottleFn

A hook that deal with the throttled function.

Overview

A hook that deal with the throttled function.

Documentation and Examples

Installation

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

A hook that deal with the throttled function.

Examples

Default usage

API

const {
  run,
  cancel,
  flush
} = useThrottleFn(
  fn: (...args: any[]) => any,
  options?: Options
);

Params

| Property | Description | Type | Default | | -- | -- | ---- | | run | Invoke and pass parameters to fn. | (...args: any[]) => any | | cancel | Cancel the invocation of currently throttled function. | () => void | | flush | Immediately invoke currently throttled function | () => void |

On this page