Connects promise to a component and provide utilities to track its execution.
Table of Contents
Why it was Built
This library is the result of deep dive into Typescript type manipulations and (what a coincidence) simplifies my daily routine on the current project 😎
npm i use-promise-connect
How to Use
The next code sample displays how to connect one promise function to use in the component. This will work the same with any amount of the promise functions.
import usePromiseConnect from "use-promise-connect";const fetchMock = valueresolve ;const AwesomeComponent =const api = ;if apifetchMockloadingreturn <p>Loading...</p>;if apifetchMockerrorreturn <p>Oops! apifetchMockerrormessage</p>;return<><button =>Click Me to Fetch Data!</button><p>Data is: apifetchMockdata</p></>;;