react-promise-hook
v1.0.1
Published
react promise a hook
Downloads
3
Maintainers
Readme
React Promise Hook
React hook with the promise that gives you an ability to react on after set effect
Usage
import usePromiseHook from 'react-promise-hook'
const App = () => {
const [test, setTest] = usePromiseHook(0)
if (!test) {
setTimeout(() => {
setTest(42).then(() => console.log('UPDATED'))
}, 2000)
}
return (
<div className="App">
<header className="App-header">
<span role="img" aria-label="img">
🤓
</span>
The Answer is {test}
</header>
</div>
)
}
export default App
Demo
Installation
npm i react-promise-hook
or
yarn add react-promise-hook
Made with ♥ by nudelx