useThrottleCallback ​
Hook that creates a throttled callback
utilities
test coverage
Last changed: 4 minutes ago
Installation ​
Library
CLI
Manual
typescript
import { useThrottleCallback } from '@siberiacancode/reactuse';
Usage ​
typescript
const throttled = useThrottleCallback(() => console.log('callback'), 500);
Demo ​
Api ​
Parameters
Name | Type | Default | Note |
---|---|---|---|
callback | (...args: Params) => Return | - | The callback function |
delay | number | - | The delay in milliseconds |
Returns
(...args: Params) => Return
Type declaration ​
typescript
export type ThrottledCallback<Params extends unknown[]> = ((...args: Params) => void) & {
cancel: () => void;
};
Source ​
Source • DemoContributors ​
D
H