mirror of
https://github.com/mue/mue.git
synced 2026-06-08 22:18:40 +02:00
32 lines
643 B
JavaScript
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;
|
|
}
|
|
}
|