useDebounce to add a delay to a action after stopping interaction. I.E. Typing into a search field, and there's a delay from stopping typing of 1 second before the search is called.
there's 3 arguments, the first is the function to delay, the second is the delay in milliseconds, and the third is the dependencies which will reset the timer.
import useDebounce from "../hooks/use-debounce";
useDebounce(() => callAPI, 1000, [searchFieldInput])
GitHub: https://github.com/sjblurton/use-debounce
NPM: https://www.npmjs.com/package/@sjblurton/use-debounce