Skip to content

Latest commit

 

History

History
19 lines (15 loc) · 407 Bytes

readme.md

File metadata and controls

19 lines (15 loc) · 407 Bytes

React Promise Component

A component which enables a function body to be invoked only once the provided promise resolves.

let promise = fetchUserFromStoreOrServer();

<PromiseComponent promise={promise}>
  {
    (error, userData) => {
      if(error) return <p className="error">{error.message}</p>;

      return (
        <UserProfile {...userData} />
      );
    }
  }
</PromiseComponent>