use-promise-manager
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

use-promise-manager

NPM JavaScript Style Guide

Install

npm install --save use-promise-manager

Usage

import * as React from "react";

import { usePromiseManager } from "use-promise-manager";
import { fetchStuff } from "fetchStuff";

const Example = () => {
  const [state, manage] = usePromiseManager();
  const [stuff, setStuff] = React.useState("");
  React.useState(() => {
    manage(fetchStuff()).then(result => setStuff(result.data));
  }, []);

  return <div>{state.isResolving ? "isLoading" : stuff}</div>;
};

License

MIT © FrimJo


This hook is created using create-react-hook.

Readme

Keywords

none

Package Sidebar

Install

npm i use-promise-manager

Weekly Downloads

19

Version

1.0.2

License

MIT

Unpacked Size

625 kB

Total Files

24

Last publish

Collaborators

  • frimjo