useThrottle()
The
useThrottle() hook limits the execution rate of a value update. Unlike debounce (which waits for a pause), throttle ensures updates happen at a regular interval (e.g., every 500ms) while the user is active. This is ideal for scroll events, resizing, or rate-limiting API calls during continuous input.Import
typescript
Usage
Type rapidly below. The Throttled value updates every 1.5s.
Real-time
0Updates
...
Throttled
0Updates
...
Component.tsx
API
Arguments
value– T The value to be throttled.interval– number (Optional) The time interval in milliseconds to wait before updating the value again. Defaults to 500ms.
Returns
Returns the throttled value of type
T.