Axinom Mosaic Libraries
    Preparing search index...

    Function useDebounce

    • Updates a value using the debounce strategy. Commonly used with the useEffect hook to check when the returned 'debouncedValue' has been updated

      Type Parameters

      • T

      Parameters

      • initialValue: T

        starting value

      • time: number

        setTimeout delay time

      Returns [T, Dispatch<T>, T]

      const [debouncedValue, setVal, val] = useDebounce<string>('intialValue', 500);
      const func = () => setVal('newValue');
      useEffect(() => {
      console.log(debouncedValue);
      }, [debouncedValue]);