use-debounce
Advanced tools
Changelog
8.0.0
useDebounce
changed its build system to microbundle. For now we have several entries:index.js
is for commonJS approach
index.modern.js
for esnext module system
index.umd.js
for UMD.
All the files are in dist
folder.
If you have any paths which have esm
or lib
, please, replace them to dist
:
Before:
import useDebounceCallback from 'use-debounce/lib/useDebounceCallback';
After:
import { useDebounceCallback } from 'use-debounce';
useDebounce
behaviour with react-devtools tab when devtools have a component with useDebounce
or useDebounceCallback
opened. https://github.com/xnimorz/use-debounce/issues/129 Thanks to @alexniarchos for reportingleading: true
https://github.com/xnimorz/use-debounce/issues/124 Thanks to @mntnoe for reportingChangelog
7.0.1
debounced
object now is preserved for use-debounce
between the renders. Thanks to @msharifi99 for reporting.Changelog
7.0.0
useDebounce
hook changed isPending
behavior from async
reacting to the sync. Now isPending
returns True
as soon as the new value is sent to the hook.Changelog
6.0.0
breaking change: removed callback
field, instead of this useDebouncedCallback
and useThrottledCallback
returns a callable function:
Old:
const { callback, pending } = useDebouncedCallback(/*...*/);
// ...
debounced.callback();
New:
const debounced = useDebouncedCallback(/*...*/);
// ...
debounced();
/**
* Also debounced has fields:
* {
* cancel: () => void
* flush: () => void
* isPending: () => boolean
* }
* So you can call debounced.cancel(), debounced.flush(), debounced.isPending()
*/
It makes easier to understand which cancel \ flush or isPending is called in case you have several debounced functions in your component
breaking change: Now useDebounce
, useDebouncedCallback
and useThrottledCallback
has isPending
method instead of pending
Old:
const { callback, pending } = useDebouncedCallback(/*...*/);
New:
const { isPending } = useDebouncedCallback(/*...*/);
/**
* {
* cancel: () => void
* flush: () => void
* isPending: () => boolean
* }
*/
get rid of useCallback
calls
improve internal typing
decrease the amount of functions to initialize each useDebouncedCallback
call
reduce library size:
Whole library: from 946 B to 899 B === 47 B useDebounce: from 844 to 791 === 53 B useDebouncedCallback: from 680 to 623 === 57 B useThrottledCallback: from 736 to 680 === 56 B
Changelog
5.2.1
useDebounce
now. https://github.com/xnimorz/use-debounce/pull/95 Thanks to @csu-feizao