Skip to main content
Version: 0.1.0

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​

ParameterTypeDefaultDescription
valueT—The value to throttle
intervalnumber500Window size in milliseconds

Return value​

The throttled value of type T.

Leading + trailing semantics​

EventBehaviour
First change in windowPasses through immediately
Subsequent changes in same windowQueued, last one wins
End of windowQueued value is emitted

Live example​

Loading playground...