import React from 'react' import PropTypes from 'prop-types' import { FormattedMessage } from 'react-intl' import { source_url, version, } from '../initial_state' import { APP_NAME, DEFAULT_REL, } from '../constants' import Button from './button' import DotTextSeperator from './dot_text_seperator' import Divider from './divider' import Icon from './icon' import Text from './text' class ErrorBoundary extends React.PureComponent { state = { hasError: false, stackTrace: undefined, componentStack: undefined, copied: false, } componentDidCatch(error, info) { this.setState({ hasError: true, stackTrace: error.stack, componentStack: info && info.componentStack, copied: false, }) } handleCopyStackTrace = () => { const { stackTrace } = this.state; const textarea = document.createElement('textarea'); textarea.textContent = stackTrace; textarea.style.position = 'fixed'; document.body.appendChild(textarea); try { textarea.select(); document.execCommand('copy'); } catch (e) { // } document.body.removeChild(textarea); this.setState({ copied: true }); setTimeout(() => this.setState({ copied: false }), 700); } render() { const { hasError, copied } = this.state if (!hasError) return this.props.children return (