Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nudelx/react-promise-hook
https://github.com/nudelx/react-promise-hook
Last synced: 16 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/nudelx/react-promise-hook
- Owner: nudelx
- Created: 2018-11-15T08:54:14.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-15T09:48:17.000Z (almost 6 years ago)
- Last Synced: 2024-04-25T15:21:33.080Z (7 months ago)
- Language: JavaScript
- Size: 1.05 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# React Promise Hook
React hook with the promise that gives you an ability to react on after set effect
## Usage
```js
import usePromiseHook from 'react-promise-hook'const App = () => {
const [test, setTest] = usePromiseHook(0)if (!test) {
setTimeout(() => {
setTest(42).then(() => console.log('UPDATED'))
}, 2000)
}return (
🤓
The Answer is {test}
)
}export default App
```## Demo
![demo](https://raw.githubusercontent.com/nudelx/react-promise-hook/master/img/demo.gif)
## Installation
```
npm i react-promise-hook
```or
```
yarn add react-promise-hook
```---
Made with ♥ by nudelx