1.1.2 • Published 5 years ago

@aslan-hooks/use-promise v1.1.2

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

use-promise

A React Hook that takes a promise which will be executed as an effect, with optional watchers

Installation Instructions

yarn add @aslan-hooks/use-promise

or

npm i --save @aslan-hooks/use-promise

Usage Instructions

import React from "react";

import usePromise from "@aslan-hooks/use-promise";

const fakeAPICall = () =>
  new Promise(resolve => {
    setTimeout(() => resolve("Text"), 1000);
  });

const Component = () => {
  const [loading, result, error, refresh] = usePromise(fakeAPICall);

  return <div>{loading ? "Loading..." : `The result is ${result}`}</div>;
};
1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago