react-data-wrapper
TypeScript icon, indicating that this package has built-in type declarations

5.0.0 • Public • Published

react-data-wrapper

Simple ReactJS component for rendering data with loading, failure & empty states.

Note: required React v16.9+

Usage

import DataWrapper from 'react-data-wrapper';

<DataWrapper
  fetcher={store.fetch}
  loading={<div>Loading posts...</div>}
  failure={<ErrorLoading />}
  isEmpty={store.empty}
  empty={<div>No data</div>}
>
  <PostsList posts={store.posts} />
</DataWrapper>

Note: ErrorLoading interface:

interface ErrorLoadingProps {
  reloading?: boolean;
  onReloadClick?: () => Promise<void>;
}

📝 Example code

Install

npm i -S react-data-wrapper

Package Sidebar

Install

npm i react-data-wrapper

Weekly Downloads

482

Version

5.0.0

License

MIT

Unpacked Size

12.5 kB

Total Files

21

Last publish

Collaborators

  • sanich