import * as React from 'react' import * as q from '../../backend/src/Model' import { Button, Modal, Paper, Toolbar, Typography, } from '@material-ui/core' import Warning from '@material-ui/icons/Warning' import SentimentDissatisfied from '@material-ui/icons/SentimentDissatisfied' import { Theme, withStyles } from '@material-ui/core/styles' interface State { error?: Error } interface Props { classes: any } class ErrorBoundary extends React.Component { constructor(props: Props) { super(props) this.state = {} } public componentDidCatch(error: Error, errorInfo: any) { console.log('did catch', error) } public static getDerivedStateFromError(error: Error) { return { error } } private restart = () => { window.location = window.location } private clearStorage = () => { localStorage.clear() window.location = window.location } public render() { if (!this.state.error) { return this.props.children } const { classes } = this.props return ( Oooooops! I hoped that you would never see this window, but MQTT-Explorer had an unexpected error.
            
              {this.state.error.stack}
            
          
Please report this issue with a short description of what happened to https://github.com/thomasnordquist/MQTT-Explorer/issues
) } } const styles = (theme: Theme) => ({ root: { minWidth: 550, maxWidth: 650, backgroundColor: theme.palette.background.default, margin: '14vh auto auto auto', padding: `${2 * theme.spacing.unit}px`, outline: 'none', }, title: { color: theme.palette.text.primary, margin: '0', textAlign: 'center' as 'center', }, textColor: { color: theme.palette.text.primary, }, buttonPositioning: { textAlign: 'center' as 'center', marginTop: `${theme.spacing.unit * 2}px`, }, }) export default withStyles(styles)(ErrorBoundary)