Returns a memoized throttled function.
The arguments of the callback.
The return type of the callback.
The function to throttle.
The throttle wait time in milliseconds.
Additional dependencies to recreate the throttled function.
Throttle options (leading, trailing, etc.).
The throttled function.
This hook wraps es-toolkit's throttle function. The callback is always up-to-date (via ref), so you don't need to include it in deps.
es-toolkit
throttle
const throttledScroll = useThrottleCallback((e) => { console.log("Scroll event", e);}, 100); Copy
const throttledScroll = useThrottleCallback((e) => { console.log("Scroll event", e);}, 100);
Returns a memoized throttled function.