Skip to content

Instantly share code, notes, and snippets.

View iamBijoyKar's full-sized avatar
🤩
Learning

Bijoy Kar iamBijoyKar

🤩
Learning
View GitHub Profile
@iamBijoyKar
iamBijoyKar / hooks.ts
Created May 10, 2025 06:48
React Debounce Hook ( useDebounce )
import { useCallback, useRef } from 'react'
/**
* A hook that returns a debounced version of the provided callback function
* @param callback The function to debounce
* @param delay The delay in milliseconds (default: 300ms)
* @returns A debounced version of the callback function
*/
export function useDebounce<T extends (...args: any[]) => any>(
callback: T,