Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 8 days 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 (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-06-08T02:28:36.000Z (over 1 year ago)
- Last Synced: 2024-10-12T00:21:32.038Z (about 1 month ago)
- Topics: async, hook, react, use-effect
- Language: TypeScript
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# react-use-effect-async
[![npm version](https://img.shields.io/npm/v/react-use-effect-async.svg)](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}
}
}
```