Skip to content

Latest commit

 

History

History
16 lines (11 loc) · 446 Bytes

use-debounced-effect.md

File metadata and controls

16 lines (11 loc) · 446 Bytes

useDebouncedEffect

Executes a side-effect based on its dependency array, but debounced by a given delay (represented as milliseconds). If delay is 0, then the effect is executed synchronously. The default delay is 0ms.

Example

const [state, setState] = useState();

useDebouncedEffect(() => {
  console.log('I am executed 500ms after `state` updates');
}, 500, [state]);

// Somewhere in the component...
setState('y0lo');