mirror of https://gitlab.com/ecentrics/concordia
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
490 B
22 lines
490 B
import React from 'react';
|
|
|
|
class ErrorBoundary extends React.Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = { hasError: false };
|
|
}
|
|
|
|
static getDerivedStateFromError() {
|
|
return { hasError: true };
|
|
}
|
|
|
|
render() {
|
|
const { props: { children }, state: { hasError } } = this;
|
|
if (hasError) {
|
|
return <h1>Something went wrong.</h1>; // TODO: Make a better "Something went wrong" screen
|
|
}
|
|
return children;
|
|
}
|
|
}
|
|
|
|
export default ErrorBoundary;
|
|
|