@thaddeusjiang/react-promise-data
v0.0.1
Published
<h1 align="center">Welcome to @thaddeusjiang/react-promise-data π</h1> <p> <a href="https://www.npmjs.com/package/@thaddeusjiang/react-promise-data" target="_blank"> <img alt="Version" src="https://img.shields.io/npm/v/@thaddeusjiang/react-promise-
Downloads
2
Maintainers
Readme
Don't wrong again about "isLoading? π : isError ? β : π"
Features
- [x] isLoading? π : isError ? β : π
Install
yarn add @thaddeusjiang/react-promise-data
Usage
export const DefaultLoading = () => {
return (
<PromiseDataRender isLoading={true} isError={false} data={'anything'}>
{({ data }) => <div>{data}</div>}
</PromiseDataRender>
);
};
export const DefaultError = () => {
return (
<PromiseDataRender isLoading={false} isError={true} data={'anything'}>
{({ data }) => <div>{data}</div>}
</PromiseDataRender>
);
};
export const DefaultData = () => {
return (
<PromiseDataRender isLoading={false} isError={false} data={'anything'}>
{({ data }) => <div>{data}</div>}
</PromiseDataRender>
);
};
export const CustomLoading = () => {
return (
<PromiseDataRender
isLoading={true}
isError={false}
data={'anything'}
loadingComponent={() => <div>π Custom Loading...</div>}
>
{({ data }) => <div>{data}</div>}
</PromiseDataRender>
);
};
export const CustomError = () => {
return (
<PromiseDataRender
isLoading={false}
isError={true}
data={'anything'}
error={new Error('π₯ Custom Error!')}
errorComponent={(error) => <div>π₯ Custom Error: {error}</div>}
>
{({ data }) => <div>{data}</div>}
</PromiseDataRender>
);
};
Development
Storybook
Run inside another terminal:
yarn storybook
Example
Then run the example inside another:
yarn link
cd example
yarn link "@thaddeusjiang/react-promise-data"
yarn # or yarn to install dependencies
yarn start #
Run tests
yarn test
Author
π€ Thaddeus Jiang
- Website: https://thaddeusjiang.com/
- Twitter: @ThaddeusJiang
- Github: @ThaddeusJiang
π€ Contributing
Contributions, issues and feature requests are welcome!Feel free to check issues page. You can also take a look at the contributing guide.
Show your support
Give a βοΈ if this project helped you!
π License
Copyright Β© 2022 Thaddeus Jiang. This project is MIT licensed.
This README was generated with β€οΈ by readme-md-generator