Skip to content

useThrottle ​

A hook that deal with the throttled value.

Code demonstration ​

API ​

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

Params ​

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

Options ​

PropertyDescriptionTypeDefault
waitThe number of milliseconds to delay.number|Ref<number>1000
leadingSpecify invoking on the leading edge of the timeout.boolean|Ref<boolean>false
trailingSpecify invoking on the trailing edge of the timeout.boolean|Ref<boolean>true

Remark

  • options.wait support dynamic changes.
  • options.leading support dynamic changes.
  • options.trailing support dynamic changes.

Source ​

Source · Document · Demo

Released under the MIT License.