https://github.com/doochik/babel-plugin-transform-react-componentdidcatch
Adds componentDidCatch to every React.(Pure)Component
https://github.com/doochik/babel-plugin-transform-react-componentdidcatch
Last synced: 5 months ago
JSON representation
Adds componentDidCatch to every React.(Pure)Component
- Host: GitHub
- URL: https://github.com/doochik/babel-plugin-transform-react-componentdidcatch
- Owner: doochik
- License: mit
- Created: 2018-06-04T10:31:42.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2025-01-15T11:56:39.000Z (over 1 year ago)
- Last Synced: 2025-10-05T16:48:49.853Z (9 months ago)
- Language: JavaScript
- Size: 174 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @doochik/babel-plugin-transform-react-componentdidcatch
Adds componentDidCatch to every React.(Pure)Component
## Installation
```sh
npm install --save-dev @doochik/babel-plugin-transform-react-componentdidcatch
```
## Usage
**You should enable this plugin only for client build**
**.babelrc**
```json
{
"plugins": [
["@doochik/babel-plugin-transform-react-componentdidcatch", {
"componentDidCatchHandler": "./path/to/my/componentDidCatchHandler.js"
}]
]
}
```
## Options
### `componentDidCatchHandler`
Path to your errorHandler module.
This is simple function with two arguments `(error, errorInfo)`
```js
// componentDidCatchHandler.js
module.exports = (error, errorINfo) => {
// here you can log error and return fallback component or null.
}
```