Rehooks
Hooks

useDebounceCallback

A custom hook that debounces a callback function, executing it after the specified delay.

useDebounceCallback

A custom hook that debounces a callback function, executing it after the specified delay.

Usage

import { useDebounceCallback } from "rehooks-ts";
 
const debouncedSave = useDebounceCallback((value) => {
  console.log("Saving data:", value);
}, 500);

API

useDebounceCallback

function useDebounceCallback<T extends (...args: any[]) => void>(
  callback: T,
  delay: number,
): (...args: Parameters<T>) => void;

Parameters

NameTypeDescription
callbackTThe callback function to debounce.
delaynumberThe debounce delay in milliseconds.

Returns

NameTypeDescription
debouncedCallback(...args: Parameters<T>) => voidA debounced version of the callback function.

On this page