Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

use-debounce

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-debounce - npm Package Compare versions

Comparing version 6.0.0-beta to 6.0.0

2

package.json
{
"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();

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc