Skip to content

Instantly share code, notes, and snippets.

View tatthien's full-sized avatar
🦄
.gitignore

Thien Nguyen tatthien

🦄
.gitignore
View GitHub Profile
@tatthien
tatthien / useDebounce.ts
Created February 15, 2024 12:53 — forked from KristofferEriksson/useDebounce.ts
A React Typescript hook that allows you to debounce any fast changing value
import { useEffect, useState } from "react";
/**
* useDebounce hook
* This hook allows you to debounce any fast changing value. The debounced value will only
* reflect the latest value when the useDebounce hook has not been called for the specified delay period.
*
* @param value - The value to be debounced.
* @param delay - The delay in milliseconds for the debounce.
* @returns The debounced value.