Last active
December 19, 2018 13:05
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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