use-state-with-callback
Advanced tools
Comparing version 2.0.1 to 2.0.2
{ | ||
"name": "use-state-with-callback", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -13,2 +13,4 @@ # useStateWithCallback React Hook | ||
**useStateWithCallback:** | ||
``` | ||
@@ -35,2 +37,6 @@ import React from 'react'; | ||
const handleClick = () => { | ||
setCount(count + 1); | ||
}; | ||
return ( | ||
@@ -40,3 +46,3 @@ <div> | ||
<button type="button" onClick={() => setCount(count + 1)}> | ||
<button type="button" onClick={handleClick}> | ||
Increase | ||
@@ -49,13 +55,46 @@ </button> | ||
**useStateWithCallbackLazy:** | ||
``` | ||
import React from 'react'; | ||
import { useStateWithCallbackLazy } from 'use-state-with-callback'; | ||
const App = () => { | ||
const [count, setCount] = useStateWithCallbackLazy(0); | ||
const handleClick = () => { | ||
setCount(count + 1, (currentCount) => { | ||
if (currentCount > 1) { | ||
console.log('Threshold of over 1 reached.'); | ||
} else { | ||
console.log('No threshold reached.'); | ||
} | ||
}); | ||
}; | ||
return ( | ||
<div> | ||
<p>{count}</p> | ||
<button type="button" onClick={handleClick}> | ||
Increase | ||
</button> | ||
</div> | ||
); | ||
}; | ||
export default App; | ||
``` | ||
## Contribute | ||
* `git clone git@github.com:the-road-to-learn-react/use-state-with-callback.git` | ||
* `cd use-state-with-callback` | ||
* `npm install` | ||
* `npm run test` | ||
- `git clone git@github.com:the-road-to-learn-react/use-state-with-callback.git` | ||
- `cd use-state-with-callback` | ||
- `npm install` | ||
- `npm run test` | ||
### More | ||
* [Publishing a Node Package to NPM](https://www.robinwieruch.de/publish-npm-package-node/) | ||
* [Node.js Testing Setup](https://www.robinwieruch.de/node-js-testing-mocha-chai/) | ||
* [React Testing Setup](https://www.robinwieruch.de/react-testing-tutorial/) | ||
- [Publishing a Node Package to NPM](https://www.robinwieruch.de/publish-npm-package-node/) | ||
- [Node.js Testing Setup](https://www.robinwieruch.de/node-js-testing-mocha-chai/) | ||
- [React Testing Setup](https://www.robinwieruch.de/react-testing-tutorial/) |
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
33369
97