Function useDebounce

Custom hook returns a debounced function.

// In this example, we create a debounced function that will print 'foo' to the console after 1 second (1000 milliseconds) of inactivity.
const debounce = useDebounce(1000);
<button onClick={() => { debounce(() => console.log('foo')); }}>print</button>
  • Parameters

    • delay: number

      The time (in milliseconds) to wait before executing the callback.

    Returns (callback: () => void) => void