Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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}

}
;
}
```