From bf9a6950ebe15540ea97969e6d985b9605065825 Mon Sep 17 00:00:00 2001
From: Alex Gleason
Date: Sat, 11 Sep 2021 18:29:43 -0500
Subject: [PATCH] Webpack: optimize ErrorBoundary
---
app/soapbox/components/error_boundary.js | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/app/soapbox/components/error_boundary.js b/app/soapbox/components/error_boundary.js
index b2b077a5f..069519f03 100644
--- a/app/soapbox/components/error_boundary.js
+++ b/app/soapbox/components/error_boundary.js
@@ -1,7 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
-import Bowser from 'bowser';
import * as Sentry from '@sentry/browser';
export default class ErrorBoundary extends React.PureComponent {
@@ -23,6 +22,14 @@ export default class ErrorBoundary extends React.PureComponent {
error,
componentStack: info && info.componentStack,
});
+
+ import(/* webpackChunkName: "error" */'bowser')
+ .then(({ default: Bowser }) => {
+ this.setState({
+ browser: Bowser.getParser(window.navigator.userAgent),
+ });
+ })
+ .catch(() => {});
}
setTextareaRef = c => {
@@ -49,9 +56,7 @@ export default class ErrorBoundary extends React.PureComponent {
}
render() {
- const browser = Bowser.getParser(window.navigator.userAgent);
-
- const { hasError } = this.state;
+ const { browser, hasError } = this.state;
if (!hasError) {
return this.props.children;
@@ -75,9 +80,9 @@ export default class ErrorBoundary extends React.PureComponent {
onClick={this.handleCopy}
readOnly
/>}
-
+ {browser &&
{browser.getBrowserName()} {browser.getBrowserVersion()}
-
+
}