Added error general error boundary page.

This commit is contained in:
Patrick Fic
2019-12-30 08:10:50 -08:00
parent 78448bbc91
commit 6f5eb87717
3 changed files with 70 additions and 35 deletions

View File

@@ -0,0 +1,31 @@
import React from "react";
class ErrorBoundary extends React.Component {
constructor() {
super();
this.state = {
hasErrored: false,
error: null
};
}
static getDerivedStateFromError(error) {
//process the error
console.log("error", error);
return { hasErrored: true, error };
}
componentDidCatch(error, info) {
console.log("error", error);
console.log("info", info);
}
render() {
if (this.state.hasErrored === true) {
return <div>Uh oh, something went wrong. {this.state.error}</div>;
} else {
return this.props.children;
}
}
}
export default ErrorBoundary;