Skip to content

Instantly share code, notes, and snippets.

@leocristofani
Last active December 19, 2018 13:05
Show Gist options
  • Save leocristofani/adbe9a9dfc66e000e028d6f4ba31f213 to your computer and use it in GitHub Desktop.
Save leocristofani/adbe9a9dfc66e000e028d6f4ba31f213 to your computer and use it in GitHub Desktop.
Micro-frontends in practice - handling errors with a React 16 Error Boundary component
class ErrorBoundary extends Component {
//...
componentDidCatch(error, info) {
this.setState({ hasError: true });
}
render() {
return this.state.hasError
? (
<div>
<p className="alert alert-warning">
Something went wrong
</p>
</div>
) : this.props.children;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment