https://github.com/abranhe/react-use-effect-async
Async useEffect hook
https://github.com/abranhe/react-use-effect-async
async hook react use-effect
Last synced: 2 months ago
JSON representation
Async useEffect hook
- Host: GitHub
- URL: https://github.com/abranhe/react-use-effect-async
- Owner: abranhe
- License: mit
- Created: 2021-11-07T01:24:35.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-12-09T13:18:33.000Z (7 months ago)
- Last Synced: 2024-12-12T21:38:23.107Z (7 months ago)
- Topics: async, hook, react, use-effect
- Language: TypeScript
- Homepage:
- Size: 12.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# react-use-effect-async
[](https://www.npmjs.com/package/react-use-effect-async)
> Async useEffect hook. Just because I was lazy to create this hook on every project.
## Install
```bash
$ npm install react-use-effect-async
```## Usage
```js
import React from 'react';
import useEffectAsync from 'react-use-effect-async';export function Demo() {
const [data, setData] = React.useState(null);useEffectAsync(async () => {
const response = await fetch('https://api.github.com/users/abranhe');
const data = await response.json();setData(data);
}, [data]);return
{!data ?;Loading...
:{data.name}
}
}
```