Utility

useThrottle

Throttle rapidly changing values to limit execution frequency.

import { useThrottle } from "saha-ui"

Uses

Throttle an invoked function to limit execution frequency; offers leading/trailing options.

Props

NameTypeDescriptionDefault
callback(...args: any[]) => voidFunction to throttle.-
delaynumberMilliseconds between allowed calls.-
options{ leading?: boolean; trailing?: boolean }Control whether the callback is fired on the leading and/or trailing edge.{ leading: true, trailing: true }

Returns

NameDescription
throttledFn(...args)Throttled wrapper function.

Example

const throttled = useThrottle(handleScroll, 200);
window.addEventListener('scroll', throttled);

Notes

Uses refs and timeouts internally to ensure proper throttling semantics.
Saha UI - The Modern React Component Library