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
| Name | Type | Description | Default |
|---|---|---|---|
| callback | (...args: any[]) => void | Function to throttle. | - |
| delay | number | Milliseconds 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
| Name | Description |
|---|---|
| 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.