shadcn-ahooks

useDebounce

A hook that deal with the debounced value.

Overview

A hook that deal with the debounced value.

Documentation and Examples

Installation

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

A hook that deal with the debounced value.

Examples

Default usage

API

const debouncedValue = useDebounce(
  value: any,
  options?: Options
);

Params

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

Options

PropertyDescriptionTypeDefault
waitThe number of milliseconds to delay.number1000
leadingSpecify invoking on the leading edge of the timeout.booleanfalse
trailingSpecify invoking on the trailing edge of the timeout.booleantrue
maxWaitThe maximum time func is allowed to be delayed before it’s invoked.number-

On this page