Skip to Content
ohooks

useThrottleValue

Throttles state updates to a value so it changes at most once per wait milliseconds.

Loading preview...

The useThrottleValue hook throttles updates to a reactive value so it changes at most once every wait milliseconds, returning a [throttledValue, controls] tuple.

Installation

pnpm dlx shadcn@latest add https://ohooks.vercel.app/r/useThrottleValue.json

Usage

Examples

Throttling Live Slider Previews

Keep a range slider responsive while throttling expensive chart or preview re-renders to once every 150ms.

Controlling Trailing Updates via Setter Controls

Use the second tuple item to flush or cancel a pending trailing value update.

API Reference

ThrottleOptions

Configuration options for leading and trailing execution edges.

Property
Specification
leading?
uniondefault:true
Invoke the function on the leading edge of the wait interval
trailing?
uniondefault:true
Invoke the function on the trailing edge of the wait interval

ThrottledFunction

Throttled setter returned as the second tuple element.

Property
Specification
cancelrequired
function
Cancels any pending trailing invocation and resets the timer.
flushrequired
function
Immediately executes any pending trailing invocation.
isPendingrequired
function
Returns true if a trailing invocation timer is currently active.