Skip to content

Instantly share code, notes, and snippets.

View apherio's full-sized avatar
🎯
Focusing

Sahil Mhapsekar apherio

🎯
Focusing
View GitHub Profile
@apherio
apherio / useDebounce.ts
Created February 28, 2021 14:03
debouncing functionality.
import { useState, useEffect } from 'react';
function useDebounce<T>(
initialValue: T,
time: number
): [T, T, React.Dispatch<T>] {
const [value, setValue] = useState<T>(initialValue);
const [debouncedValue, setDebouncedValue] = useState<T>(initialValue);
useEffect(() => {