Skip to content

dmaria58/react-catch-errors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-catch-errors

A React Transform that catches errors inside render() function and renders a React component with an error message instead.

It’s up to you to choose the React component to render an error message.

解决react内部抛错导致的页面空白无法执行的问题。具体安装步骤如下

Installation

First, install the [Babel plugin]

npm install --save-dev babel-plugin-react-transform

Then, install the transform:

npm install --save-dev react-catch-errors

You may also use a custom component instead.

Now edit your .babelrc to include extra.babel-plugin-react-transform.
It must be an array of the transforms you want to use:

{
  "presets": ["es2015", "stage-0"],
  "plugins": [["react-transform", {
    "transforms": [{
      "transform": "react-catch-errors",
      // now go the imports!
      "imports": [
        "react"
      ]
    }]
  }]]
}

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •