import React from "react"; const useDebounce = (value: T, delay: number) => { const [debouncedValue, setDebouncedValue] = React.useState(value); React.useEffect(() => { const timer = setTimeout(() => { setDebouncedValue(value); }, delay); return () => { clearTimeout(timer); }; }, [value, delay]); return debouncedValue; }; export default useDebounce;