import "./error-boundary.scss" import React, { ErrorInfo } from "react"; import { reaction } from "mobx"; import { disposeOnUnmount, observer } from "mobx-react"; import { t, Trans } from "@lingui/macro"; import { Button } from "../button"; import { configStore } from "../../config.store"; import { navigation } from "../../navigation"; import { _i18n } from "../../i18n"; interface Props { } interface State { error?: Error; errorInfo?: ErrorInfo; } @observer export class ErrorBoundary extends React.Component { public state: State = {}; @disposeOnUnmount resetOnNavigate = reaction( () => navigation.getPath(), () => this.setState({ error: null, errorInfo: null }) ) componentDidCatch(error: Error, errorInfo: ErrorInfo) { this.setState({ error, errorInfo }); } back = () => { navigation.goBack(); } render() { const { error, errorInfo } = this.state; if (error) { const slackLink = Kontena Slack const githubLink = Kontena Github const pageUrl = location.href; return (
App crash at {pageUrl} {configStore.buildVersion &&

Build version: {configStore.buildVersion}

}

To help us improve the product please report bugs to {slackLink} community or {githubLink} issues tracker.

Component stack:

{errorInfo.componentStack}

Error stack:


{error.stack}
) } return this.props.children; } }