2.0.0 • Published 8 years ago

react-safe-render v2.0.0

Weekly downloads
583
License
MIT
Repository
github
Last release
8 years ago

React Safe Render Build Status NPM version

Helper to make sure your react components do not kill your entire application when their lifecylce methods fail.

Usage

Before any other components are created

var React = require('react');

require('react-safe-render')(React, {
  errorHandler: function (errReport) {
    
    // if a component fails you can handle the failure however you want
    
    errReport.displayName // name of component that failed
    errReport.props // the props that the component recieved
    errReport.method // name of method that failed (ie: componentWillMount)
    errReport.arguments // arguments for the method that failed (if there were any)
    errReport.error // the original error object
  }
});

Note on es2015

At the moment this only works for components made via React.createClass(). It will not catch errors if you use the Component class directly.

Disable for a single component

If you want to disable the error handler for a component, you can use a static property

React.createClass({
  statics: {
    bubbleErrors: true
  },

  // ...

});

License

MIT

2.0.0

8 years ago

1.0.4

9 years ago

0.0.3

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.0.0

9 years ago