use-function-debouncer

2.0.0 • Public • Published

useFunctionDebouncer

useFunctionDebouncer is a React hook which can debounce (or delay) a function and provide a method to cancel the function.


What is debouncing?

Debouncing means delaying a function call.

 

How do I use it?

Use it like this:
const [debounce, cancelDebounce] = useFunctionDebouncer()

Pass a function to debounce and a time delay (in ms) to debounce it by like this:
debounce(() => console.log("Debounce me!"), 1000)

That will run console.log(...) after 1 second (1000 ms)

 

What else can I do?

If you'd like to cancel the function's execution during the debounce, run cancelDebounce()

Readme

Keywords

none

Package Sidebar

Install

npm i use-function-debouncer

Weekly Downloads

1

Version

2.0.0

License

MIT

Unpacked Size

13.6 kB

Total Files

7

Last publish

Collaborators

  • aej11a