Merge branch 'optimize-error-boundary' into 'develop'
Webpack: optimize ErrorBoundary See merge request soapbox-pub/soapbox-fe!744
This commit is contained in:
commit
139b47eb22
|
@ -1,7 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import Bowser from 'bowser';
|
|
||||||
import * as Sentry from '@sentry/browser';
|
import * as Sentry from '@sentry/browser';
|
||||||
|
|
||||||
export default class ErrorBoundary extends React.PureComponent {
|
export default class ErrorBoundary extends React.PureComponent {
|
||||||
|
@ -23,6 +22,14 @@ export default class ErrorBoundary extends React.PureComponent {
|
||||||
error,
|
error,
|
||||||
componentStack: info && info.componentStack,
|
componentStack: info && info.componentStack,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
import(/* webpackChunkName: "error" */'bowser')
|
||||||
|
.then(({ default: Bowser }) => {
|
||||||
|
this.setState({
|
||||||
|
browser: Bowser.getParser(window.navigator.userAgent),
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
setTextareaRef = c => {
|
setTextareaRef = c => {
|
||||||
|
@ -49,9 +56,7 @@ export default class ErrorBoundary extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const browser = Bowser.getParser(window.navigator.userAgent);
|
const { browser, hasError } = this.state;
|
||||||
|
|
||||||
const { hasError } = this.state;
|
|
||||||
|
|
||||||
if (!hasError) {
|
if (!hasError) {
|
||||||
return this.props.children;
|
return this.props.children;
|
||||||
|
@ -75,9 +80,9 @@ export default class ErrorBoundary extends React.PureComponent {
|
||||||
onClick={this.handleCopy}
|
onClick={this.handleCopy}
|
||||||
readOnly
|
readOnly
|
||||||
/>}
|
/>}
|
||||||
<p className='error-boundary__browser'>
|
{browser && <p className='error-boundary__browser'>
|
||||||
{browser.getBrowserName()} {browser.getBrowserVersion()}
|
{browser.getBrowserName()} {browser.getBrowserVersion()}
|
||||||
</p>
|
</p>}
|
||||||
<p className='help-text'>
|
<p className='help-text'>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='alert.unexpected.help_text'
|
id='alert.unexpected.help_text'
|
||||||
|
|
Loading…
Reference in New Issue