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> Copy
// 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>
The time (in milliseconds) to wait before executing the callback.
Custom hook returns a debounced function.
Example