useThrottleCallback
Creates a throttled version of a callback that executes at most once every wait milliseconds.
Loading preview...
The useThrottleCallback hook returns a stable, throttled version of a callback that executes at most once per wait milliseconds, supporting leading and trailing execution edges as well as .cancel(), .flush(), and .isPending() controls.
Installation
Usage
Examples
Throttling Window or Container Events
Limit how frequently an expensive handler runs during continuous scroll or resize events.
Flushing or Cancelling a Trailing Call
Use .flush() to immediately run a pending trailing invocation or .cancel() to discard it.
API Reference
ThrottleOptions
Configuration options for leading and trailing execution edges.
Property
Specification
leading?uniondefault:true
Invoke the function on the leading edge of the wait interval
Full Signature
trailing?uniondefault:true
Invoke the function on the trailing edge of the wait interval
Full Signature
ThrottledFunction
Throttled function returned by the hook, augmented with .cancel(), .flush(), and .isPending().
Property
Specification
cancelrequiredfunction
Cancels any pending trailing invocation and resets the timer.
Full Signature
flushrequiredfunction
Immediately executes any pending trailing invocation.
Full Signature
isPendingrequiredfunction
Returns
true if a trailing invocation timer is currently active.Full Signature