Files
mue/src/components/modals/ErrorBoundary.jsx
2021-03-20 12:55:20 +00:00

32 lines
643 B
JavaScript

import React from 'react';
export default class ErrorBoundary extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
error: false
};
}
static getDerivedStateFromError(error) {
console.log(error);
return {
error: true
};
}
render() {
if (this.state.error) {
return (
<div style={{'textAlign': 'center'}}>
<h1>Error</h1>
<p>Failed to load this component of Mue.</p>
<button className='refresh' onClick={() => window.location.reload()}>Refresh</button>
</div>
);
}
return this.props.children;
}
}