mirror of
https://github.com/mue/mue.git
synced 2026-07-23 00:37:27 +02:00
refactor: make modals like widgets
This commit is contained in:
31
src/components/modals/ErrorBoundary.jsx
Normal file
31
src/components/modals/ErrorBoundary.jsx
Normal file
@@ -0,0 +1,31 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user