react-promiser
v0.2.1
Published
A react component to help manage promises
Downloads
4
Readme
React Promiser
A react component to help manage promises
Example
import { Promiser } from 'react-promiser';
import fetchMyData from './fetch';
import * as State from './states';
function MyComponent() {
return (
<Promiser auto promise={fetchMyData}>
{({ result, error, pending, fulfilled, rejected }) => {
if (pending) return <State.Loading />;
if (rejected) return <State.Error error={error} />;
if (fulfilled && result) return <State.Result result={result} />;
return <State.Empty />;
}}
</Promiser>
);
}
License
The MIT License (MIT). Please see License File for more information.