Skip to content

useThrottleCallback

Hook that creates a throttled callback

utilities
medium
test coverage
Last changed: 7 months ago

Installation

Library
CLI
Manual
typescript
import { useThrottleCallback } from '@siberiacancode/reactuse';

Usage

typescript
const throttled = useThrottleCallback(() => console.log('callback'), 500);

Demo

Api

Parameters

NameTypeDefaultNote
callback(...args: Params) => Return-The callback function
delaynumber-The delay in milliseconds

Returns

(...args: Params) => Return

Type declaration

typescript
export type ThrottledCallback<Params extends unknown[]> = ((...args: Params) => void) & {
  cancel: () => void;
};

Source

SourceDemo

Contributors

D
debabin
debabin
H
hywax
hywax

Released under the MIT License.