# react-with-loading-srian

> React loading HOC

Latest version **1.2.3** (published 2020-03-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-with-loading-srian
pnpm add react-with-loading-srian
yarn add react-with-loading-srian
bun add react-with-loading-srian
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.3 |
| Published | 2020-03-29 |
| First published | 2020-03-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | srianbury |
| Keywords | React, Loading, HOC, fetch, fallback |

## Links

- npm: https://www.npmjs.com/package/react-with-loading-srian
- Repository: https://github.com/srianbury/react-with-loading
- Homepage: https://github.com/srianbury/react-with-loading#readme
- Issues: https://github.com/srianbury/react-with-loading/issues
- npm.io page: https://npm.io/package/react-with-loading-srian

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.2.3 (latest) — 2020-03-29
- 1.2.2 — 2020-03-24
- 1.2.1 — 2020-03-15
- 1.2.0 — 2020-03-15
- 1.1.4 — 2020-03-14
- 1.1.3 — 2020-03-14
- 1.1.2 — 2020-03-14
- 1.1.1 — 2020-03-14
- 1.1.0 — 2020-03-14
- 1.0.0 — 2020-03-14

## README

# react-with-loading 

react-with-loading-srian is a react HOC that shows your data after it's been fetched, a loader when it's loading, and an error if it fails.

[![Build Status](https://travis-ci.org/srianbury/react-with-loading.svg?branch=master)](https://travis-ci.org/srianbury/react-with-loading) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) [![Coverage Status](https://coveralls.io/repos/github/srianbury/react-with-loading/badge.svg)](https://coveralls.io/github/srianbury/react-with-loading)

### Install
`npm i react-with-loading-srian`

### Quick Start Example
##### Write your view as normal
```
const View = ({ id, title, completed }) => (
  <div>
    <div>ID: {id}</div>
    <div>Title: {title}</div>
    <div>Completed? {completed ? 'Yes' : 'No'}</div>
  </div>
);
```
##### Wrap it in withLoading
```
const ViewWithLoading = withLoading(View);
```
##### Use the Wrapped component and pass it a loading prop
```
<ViewWithLoading loading={!state} {...state} />
```
![Basic Example](https://github.com/srianbury/react-with-loading/blob/master/images/basic_example.PNG)

[![Edit with-loading-basic](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/confident-archimedes-om29l?fontsize=14&hidenavigation=1&theme=dark)

### Advanced Use Example
[![Edit with-react-loading-advanced-usage](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/festive-wildflower-xxtpr?fontsize=14&hidenavigation=1&theme=dark)

### PropTypes
```
withLoading.propTypes = {
  Component: PropTypes.element,
  FallbackOptions: PropTypes.shape({  // FallbackOptions allows you to write your own HOC with your own default Fallbacks
    LoadingFallback: PropTypes.func,
    ErrorFallback: PropTypes.func,
  }),
};
```
```
Wrapped.propTypes = {
  loading: PropTypes.bool.isRequired,
  error: PropTypes.any,
  LoadingFallback: PropTypes.func,
  ErrorFallback: PropTypes.func,
};
```

---
_Source: https://npm.io/package/react-with-loading-srian · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
