useThrottle
@guoba-ai/hook / useThrottle
Function: useThrottle()
function useThrottle<T>(value, interval?): T;Defined in: useThrottle.ts:16
Throttle a value. The returned value updates at most once per interval.
Type Parameters
T
T
Parameters
value
T
The value to throttle
interval?
number = 500
Minimum time between updates in milliseconds (defaults to 500)
Returns
T
The throttled value
Example
const [position, setPosition] = useState({ x: 0, y: 0 })
const throttledPosition = useThrottle(position, 100)
// throttledPosition updates at most once every 100ms