import "./error-boundary.scss"; import React, { ErrorInfo } from "react"; import { reaction } from "mobx"; import { disposeOnUnmount, observer } from "mobx-react"; import { Button } from "../button"; import { navigation } from "../../navigation"; import { issuesTrackerUrl, slackUrl } from "../../../common/vars"; 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 = Slack; const githubLink = Github; const pageUrl = location.href; return (
App crash at {pageUrl}

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; } }