useDebounce

A hook for debouncing callback functions with cancel functionality

Preview

Basic Debounce

Current:

Debounced (500ms):

With Cancel

Installation

Usage

API Reference

Parameters

ParameterTypeDescription
callback(value: string) => voidThe function to debounce
delaynumberThe delay in milliseconds

Return Value

Returns a debounced function with a cancel method attached to it.

PropertyTypeDescription
debouncedFn(value: string) => voidThe debounced function
cancel() => voidCancels any pending debounced calls

Examples

Basic Usage

With Cancel