# react-error-catcher

> A powerful react error catcher!

Latest version **1.2.0** (published 2021-04-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-error-catcher
pnpm add react-error-catcher
yarn add react-error-catcher
bun add react-error-catcher
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2021-04-29 |
| First published | 2020-09-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 19.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Y-lonelY |
| Maintainers | ylonely |
| Keywords | ["react", "error", "catch"] |

## Links

- npm: https://www.npmjs.com/package/react-error-catcher
- Repository: https://github.com/Y-lonelY/react-error-catcher
- Homepage: https://github.com/Y-lonelY/react-error-catcher#readme
- Issues: https://github.com/Y-lonelY/react-error-catcher/issues
- npm.io page: https://npm.io/package/react-error-catcher

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 1.2.0 (latest) — 2021-04-29
- 1.1.5 — 2020-11-29
- 1.1.4 — 2020-09-22
- 1.1.3 — 2020-09-20
- 1.1.2 — 2020-09-15
- 1.1.1 — 2020-09-14
- 1.1.0 — 2020-09-14
- 1.0.9 — 2020-09-14
- 1.0.8 — 2020-09-12
- 1.0.7 — 2020-09-12
- 1.0.6 — 2020-09-11
- 1.0.5 — 2020-09-10
- 1.0.4 — 2020-09-10
- 1.0.3 — 2020-09-08
- 1.0.2 — 2020-09-07
- … 2 more at https://npm.io/package/react-error-catcher/versions

## README

English | [简体中文](./README.zh-CN.md)

# React Error Catcher 🍑

This is a powerful **React** error catcher!

It can catch these below:
- React component render error, use [Error Bounary](https://zh-hans.reactjs.org/docs/error-boundaries.html)
- Event error, use [onError](https://developer.mozilla.org/zh-CN/docs/Web/API/ErrorEvent)
- Promise error, use [PromiseRejectionEvent](https://developer.mozilla.org/zh-CN/docs/Web/API/PromiseRejectionEvent)

When error catched, you will get a list of errors by **onCatch** event

As we all konw, sometime errors can be too much to handle, so i filter the mutiple errors, also i support the **filters** for you to define which error can be ignored!



### Install 

Run `npm install react-error-catcher` or `yarn add react-error-catcher` to install it

Then you can use it in your project like this:

```javascript
import ErrorCatcher from 'react-error-catcher'

const App = () => {
  return (<ErrorCatcher>
    <Main />
    </ErrorCatcher>)
}

export default App
```



## Props

| properity   | description                                                  | type                        | default                         |
| ----------- | ------------------------------------------------------------ | --------------------------- | ------------------------------- |
| errorRender | when an error occurs in component rendering, decide which lower layer component to display | React.ReactNode             | \<h1>Something went wrong\</h1> |
| user        | who cause the error                                          | string                      | "unkonwn user"                  |
| app         | error occurs in which app                                    | string                      | "unkonwn app"                   |
| max         | when the catched errors exceeds the max value,  trigger the callback method | number                      | 1                               |
| delay       | report error interval, unit is millisecond                   | number                      | 60000                           |
| filters     | define the errors which can be ignored                       | string[]                    | -                               |
| onCatch     | callback when catching errors and achieving the trigger cases | (error: ErrorInfo[]) => any | -                               |



## About

If you want to develop a npm library, you can see [npm-template](https://github.com/Y-lonelY/npm-template), welecome to star and fork!

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