npm.io
1.2.0 • Published 5 years ago

react-error-catcher

Licence
MIT
Version
1.2.0
Deps
0
Size
20 kB
Vulns
0
Weekly
0
Stars
2

English | 简体中文

React Error Catcher

This is a powerful React error catcher!

It can catch these below:

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:

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, welecome to star and fork!

Keywords