@doochik/babel-plugin-transform-react-componentdidcatch

Adds componentDidCatch to every React.(Pure)Component

Stats

StarsIssuesVersionUpdatedCreatedSize
@doochik/babel-plugin-transform-react-componentdidcatch
001.0.13 years ago3 years agoMinified + gzip package size for @doochik/babel-plugin-transform-react-componentdidcatch in KB

Readme

Build Status

@doochik/babel-plugin-transform-react-componentdidcatch

Adds componentDidCatch to every React.(Pure)Component

Installation

npm install --save-dev @doochik/babel-plugin-transform-react-componentdidcatch

Usage

You should enable this plugin only for client build

.babelrc

{
    "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)

// componentDidCatchHandler.js

module.exports = (error, errorINfo) => {
   // here you can log error and return fallback component or null.
}

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.