1.0.2 • Published 3 years ago

react-use-effect-async v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

react-use-effect-async

npm version

Async useEffect hook. Just because I was lazy to create this hook on every project.

Install

$ npm install react-use-effect-async

Usage

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 <div>{!data ? <p>Loading...</p> : <p>{data.name}</p>}</div>;
}
1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago