useThrottledCallback
useThrottledCallback<
Args>(fn,delay,options?):ThrottledCallback<Args>
Defined in: src/hooks/useThrottledCallback/useThrottledCallback.ts:30
Wrap a function so it fires at most once per delay ms. With both
leading and trailing enabled (the default), the first call fires
immediately and the most recent call inside the window fires at its
end. Set leading: false to defer the first call; set
trailing: false to drop calls inside the window.
Typical use: drag handlers, scroll listeners, resize observers — places where the input rate exceeds the work rate and you want to bound the latter.
The wrapper identity is stable across renders.
Type Parameters
Section titled “Type Parameters”Args extends unknown[]
Parameters
Section titled “Parameters”(…args) => void
number
options?
Section titled “options?”UseThrottledCallbackOptions = {}
Returns
Section titled “Returns”ThrottledCallback<Args>
Example
Section titled “Example”const onPointerMove = useThrottledCallback(updateGuide, 16);