@sjblurton/use-debounce
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

useDebounce

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 the hook...

import useDebounce from "../hooks/use-debounce";

To call the hook...

useDebounce(() => callAPI, 1000, [searchFieldInput])

Links

GitHub: https://github.com/sjblurton/use-debounce
NPM: https://www.npmjs.com/package/@sjblurton/use-debounce

Package Sidebar

Install

npm i @sjblurton/use-debounce

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

7.89 kB

Total Files

15

Last publish

Collaborators

  • sjblurton