Skip to main content

Variable: useThrottle

const useThrottle: <T>(value, delay, options?) => T = useThrottledValue

Defined in: use-throttle.ts:29

Returns a throttled copy of value that updates at most once per delay milliseconds.

Returns a throttled copy of value that updates at most once per delay milliseconds. It is the value-based counterpart to useDebounce.

A throttle window starts when a change arrives while none is active. With leading (default) the change is emitted immediately; with trailing (default) the latest value seen during the window is emitted when it ends, which starts a new window. The initial value is returned as-is on the first render. With both options false, the returned value never updates. Pending timers are cleared on unmount.

Type Parameters​

T​

T

The type of the value to throttle.

Parameters​

value​

T

The value to throttle.

delay​

number

The minimum interval between updates, in milliseconds.

options?​

UseThrottledValueOptions

Optional leading/trailing behavior.

Returns​

T

The throttled value.

Examples​

const [scrollY, setScrollY] = useState(0);
const throttledScrollY = useThrottledValue(scrollY, 200);
// Only emit at the end of each window
const throttledQuery = useThrottledValue(query, 500, { leading: false });

For a live, editable example, see the useThrottledValue docs page.

Deprecated​

Renamed to useThrottledValue so the name says it throttles a value, matching useDebouncedValue and useDebouncedCallback. It behaves exactly the same; replace the import. This alias will be removed in a future release.

Example​

// Before
const throttled = useThrottle(value, 200);
// After
const throttled = useThrottledValue(value, 200);