/* eslint-disable react/destructuring-assignment */ import React from 'react'; import { version as appVersion } from '../../../../package.json'; import { LoggingContext } from '../../context/LoggingContext'; import style from './ErrorBoundary.module.scss'; class ErrorBoundary extends React.Component { static contextType = LoggingContext; reportContent = ''; constructor(props) { super(props); this.state = { error: null, errorInfo: null }; } static getDerivedStateFromError(error) { // Update state so next render shows fallback UI. return { errorMessage: error.toString() }; } componentDidCatch(error, info) { this.setState({ error: error, errorInfo: info, }); try { this.context.emitError(error.toString()); } catch (e) { console.log('Unable to emit error', error, e); } this.reportContent = `${error} ${info.componentStack}`; } render() { if (this.state.errorMessage) { return (
:/
Something went wrong