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

1.1.2 • Public • Published

@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.
}

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.2
    45
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.1.2
    45
  • 1.1.0
    34
  • 1.0.1
    4
  • 1.0.0
    5

Package Sidebar

Install

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

Weekly Downloads

19

Version

1.1.2

License

MIT

Unpacked Size

6.63 kB

Total Files

4

Last publish

Collaborators

  • doochik