Added error general error boundary page.
This commit is contained in:
@@ -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;
|
||||
Reference in New Issue
Block a user