# react-view-status

> State management without hassle.

Latest version **1.0.1** (published 2018-11-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-view-status
pnpm add react-view-status
yarn add react-view-status
bun add react-view-status
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2018-11-28 |
| First published | 2018-11-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 11 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Petr Hanak |
| Maintainers | petrhanak |

## Links

- npm: https://www.npmjs.com/package/react-view-status
- Repository: https://github.com/petrhanak/react-view-status
- Homepage: https://github.com/petrhanak/react-view-status#readme
- Issues: https://github.com/petrhanak/react-view-status/issues
- npm.io page: https://npm.io/package/react-view-status

## Recent versions

- 1.0.1 (latest) — 2018-11-28
- 1.0.0 — 2018-11-28

## README

# react-view-status 

 

## View lifecycle

`uninitialized`: No data to display, only loader will be present.

`default`: User interaction available, but there still might be error passed in default state. There is special case for empty array passed in `props.data` showing `<NoDataComponent />`. 

`loading`: Data turned up in loading state while there is still previous state available to show, e.g. user is sending form, list is refreshing.


`finite`, `crash`: Data flow is finished with no more interaction available for user
successful sign up, filled form, component failed loading.

### How to use

First provide config for hoc, all components are optional.

```
// status.js
import withStatus from 'react-view-lifecycle'
 
const Loader = props => <div>loading...</div>
const Error = props => <div>something bad happened</div>
const NoData = props => <div>no data to display</div>
 
export default withStatus({
  loader: MyLoader,
  error: Error,
  noData: NoData,
})
```

Then wrap component showing data with this hoc and pass `status`, `error` and `data` in props from parent component.

```
import status from './status'

const MyComponent = props => (...)

export default status(MyComponent);
```

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