Need private packages and team management tools?Check out npm Teams »

use-promise-manager

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.

Keywords

none

Install

npm i use-promise-manager

DownloadsWeekly Downloads

3

Version

1.0.2

License

MIT

Unpacked Size

625 kB

Total Files

24

Last publish

Collaborators

  • avatar