use-debounce
Advanced tools
Comparing version 6.0.0-beta to 6.0.0
{ | ||
"name": "use-debounce", | ||
"version": "6.0.0-beta", | ||
"version": "6.0.0", | ||
"description": "Debounce hook for react", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -96,6 +96,6 @@ <div align="center"> | ||
// you should use `e => debounced.callback(e.target.value)` as react works with synthetic events | ||
// you should use `e => debounced(e.target.value)` as react works with synthetic events | ||
return ( | ||
<div> | ||
<input defaultValue={defaultValue} onChange={(e) => debounced.callback(e.target.value)} /> | ||
<input defaultValue={defaultValue} onChange={(e) => debounced(e.target.value)} /> | ||
<p>Debounced value: {value}</p> | ||
@@ -128,3 +128,3 @@ </div> | ||
useEffect(() => { | ||
const unsubscribe = subscribe(window, 'scroll', debounced.callback); | ||
const unsubscribe = subscribe(window, 'scroll', debounced); | ||
return () => { | ||
@@ -146,5 +146,5 @@ unsubscribe(); | ||
### Returned value from `debounced.callback` | ||
### Returned value from `debounced()` | ||
Subsequent calls to the debounced function `debounced.callback` return the result of the last func invocation. | ||
Subsequent calls to the debounced function `debounced` return the result of the last func invocation. | ||
Note, that if there are no previous invocations it's mean you will get undefined. You should check it in your code properly. | ||
@@ -155,3 +155,3 @@ | ||
```javascript | ||
it('Subsequent calls to the debounced function `debounced.callback` return the result of the last func invocation.', () => { | ||
it('Subsequent calls to the debounced function `debounced` return the result of the last func invocation.', () => { | ||
const callback = jest.fn(() => 42); | ||
@@ -162,3 +162,3 @@ | ||
const debounced = useDebouncedCallback(callback, 1000); | ||
callbackCache = debounced.callback; | ||
callbackCache = debounced; | ||
return null; | ||
@@ -208,6 +208,6 @@ } | ||
// you should use `e => debounced.callback(e.target.value)` as react works with synthetic events | ||
// you should use `e => debounced(e.target.value)` as react works with synthetic events | ||
return ( | ||
<div> | ||
<input defaultValue={defaultValue} onChange={(e) => debounced.callback(e.target.value)} /> | ||
<input defaultValue={defaultValue} onChange={(e) => debounced(e.target.value)} /> | ||
<p>Debounced value: {value}</p> | ||
@@ -248,3 +248,3 @@ <button onClick={debounced.cancel}>Cancel Debounce cycle</button> | ||
return <input defaultValue={defaultValue} onChange={(e) => debounced.callback(e.target.value)} />; | ||
return <input defaultValue={defaultValue} onChange={(e) => debounced(e.target.value)} />; | ||
} | ||
@@ -262,3 +262,3 @@ ``` | ||
expect(debounced.pending()).toBeFalsy(); | ||
debounced.callback(); | ||
debounced(); | ||
expect(debounced.pending()).toBeTruthy(); | ||
@@ -265,0 +265,0 @@ debounced.flush(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
68968