1.2.0 • Published 3 years ago
react-error-catcher v1.2.0
English | 简体中文
React Error Catcher 🍑
This is a powerful React error catcher!
It can catch these below:
- React component render error, use Error Bounary
- Event error, use onError
- Promise error, use 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:
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 | \Something went wrong\ |
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!