# react-resilent

> A high order component for resilently render errored components

Latest version **0.3.0** (published 2017-03-21) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install react-resilent
pnpm add react-resilent
yarn add react-resilent
bun add react-resilent
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2017-03-21 |
| First published | 2017-03-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Albert Fernández |
| Maintainers | albertfdp |

## Links

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

## Recent versions

- 0.3.0 (latest) — 2017-03-21
- 0.2.0 — 2017-03-21
- 0.1.1 — 2017-03-19
- 0.1.0 — 2017-03-19

## README

# react-resilent

[![Build Status](https://travis-ci.org/albertfdp/react-resilent.svg?branch=master)](https://travis-ci.org/albertfdp/react-resilent)

A high order component for resilently render components that might fail. It wraps them around a React Fiber error boundary.

* Tries to render your component
* Returns `<FallbackComponent />` after the maximum number of retries (`props.maxRetries`)

---

#### ⚠️ DISCLAIMER: Experimental
This **ONLY** works with `react@next` (Fiber).

---

### [Demo](https://albertfdp.github.io/react-resilent)

```js
import React from 'react'
import Resilent from 'react-resilent'

const Broken = () => {
  throw new Error('Broken!')
}

const ResilentComponent = Resilent({
  FallbackComponent: () => <div>Fallback component</div>
})(Broken)

export default class Application extends React.Component {
  onError = (error) => {
    console.error('Error catched', error)
  }
  
  render () {
    return (
      <ResilentComponent
        maxRetries={2}
        onError={this.onError}
      />
    )
  }
}
```

### API

```js
const MyResilentComponent = Resilent({
  FallbackComponent: React.Component
})(React.Component)


<MyResilentComponent
  maxRetries={number}
  onError={func}
/>
```

##### `opts.FallbackComponent`

React component displayed after the `maxRetries`

##### `props.maxRetries` (optional, defaults to 0)

Number of retries before showing the `FallbackComponent`

##### `props.onError` (optional)

Callback for when errors are thrown

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