useThrottle
Returns a throttled copy of a value. The first change within an interval passes through immediately (leading edge), and the last change within that window is scheduled at the end of the interval (trailing edge).
Signature
function useThrottle<T>(value: T, interval?: number): T
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
value | T | — | The value to throttle |
interval | number | 500 | Window size in milliseconds |
Return value
The throttled value of type T.
Leading + trailing semantics
| Event | Behaviour |
|---|---|
| First change in window | Passes through immediately |
| Subsequent changes in same window | Queued, last one wins |
| End of window | Queued value is emitted |
Live example
Loading playground...