5.0.0 ā¢ Published 3 years ago
react-data-wrapper v5.0.0
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