SanichKotikov / react-data-wrapper

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react-data-wrapper

Simple React component (713 B) for rendering data with loading, failure & empty states.

Usage

npm i -S react-data-wrapper
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>

ErrorLoading interface:

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

About

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

License:MIT License


Languages

Language:TypeScript 99.0%Language:JavaScript 1.0%