1 import { useCallback, useEffect, useState } from 'react';
3 import _debounce from '@proton/utils/debounce';
5 export const useDebouncedValue = <T extends string | number>(valueIn: T, time: number): T => {
6 const [valueOut, setValueOut] = useState(valueIn);
7 const debounce = useCallback(
8 _debounce((value) => setValueOut(value), time, { leading: true }),
11 useEffect(() => debounce(valueIn), [valueIn]);
12 useEffect(() => () => debounce.cancel(), []);