Back to Hooks

useDebounce

packages/hooks/src/useDebounce/index.en-US.md

3.9.71.1 KB
Original Source

useDebounce

A hook that deal with the debounced value.

Examples

Default usage

<code src="./demo/demo1.tsx" />

API

typescript
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-