2019-03-15 04:35:45 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2019-09-17 19:22:29 +00:00
|
|
|
import defaultmascotlight from '../../images/defaultmascotlight.svg';
|
|
|
|
import defaultmascotdark from '../../images/defaultmascotdark.svg';
|
|
|
|
import {svgSelect} from '../features/compose/util/svg_select';
|
2019-03-15 04:35:45 +00:00
|
|
|
|
|
|
|
export default class ErrorBoundary extends React.PureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
children: PropTypes.node,
|
|
|
|
};
|
|
|
|
|
|
|
|
state = {
|
|
|
|
hasError: false,
|
|
|
|
stackTrace: undefined,
|
|
|
|
componentStack: undefined,
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidCatch(error, info) {
|
|
|
|
this.setState({
|
|
|
|
hasError: true,
|
|
|
|
stackTrace: error.stack,
|
|
|
|
componentStack: info && info.componentStack,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { hasError } = this.state;
|
|
|
|
|
|
|
|
if (!hasError) {
|
|
|
|
return this.props.children;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
2019-09-17 19:22:29 +00:00
|
|
|
<img src={svgSelect(defaultmascotlight, defaultmascotdark)} alt='' />
|
2019-03-15 04:35:45 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|