Skip to content

Instantly share code, notes, and snippets.

@cmilfont
Last active November 6, 2017 11:47
Show Gist options
  • Save cmilfont/e4fa20e1ced19a36fcdf948916184ade to your computer and use it in GitHub Desktop.
Save cmilfont/e4fa20e1ced19a36fcdf948916184ade to your computer and use it in GitHub Desktop.
import React from 'react';
import { connect } from 'react-redux';
import { actions, mapDispatchToProps} from 'api/actions/errors';
class ErrorBoundary extends React.Component {
componentDidCatch(error, info) {
this.props.dispatch({
type: actions.GLOBAL_EXCEPTION,
payload: {
error,
info,
});
// Ou um método mapeado no mapDispatchToProps
// this.props.logErrorToStore({ error, info });
}
render() {
return this.props.children;
}
}
export default connect(null, mapDispatchToProps)(ErrorBoundary);
/*...*/
<Provider store={store}>
<ErrorBoundary>
<App />
</ErrorBoundary>
</Provider>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment