Don't lazy-load components in ErrorBoundary
We currently handle major errors through ErrorBoundary. If the error is network related, ErrorBoundary ends up blank if it's components are lazy-loaded. #codesplit
This commit is contained in:
parent
3fad222848
commit
3017155867
1 changed files with 24 additions and 27 deletions
|
@ -1,15 +1,14 @@
|
|||
// @flow
|
||||
import type { Node } from 'react';
|
||||
import React from 'react';
|
||||
import Yrbl from 'component/yrbl';
|
||||
import Button from 'component/button';
|
||||
import { withRouter } from 'react-router';
|
||||
import analytics from 'analytics';
|
||||
import I18nMessage from 'component/i18nMessage';
|
||||
import Native from 'native';
|
||||
import { Lbry } from 'lbry-redux';
|
||||
|
||||
const Button = React.lazy(() => import('component/button' /* webpackChunkName: "button" */));
|
||||
const I18nMessage = React.lazy(() => import('component/i18nMessage' /* webpackChunkName: "i18nMessage" */));
|
||||
const Yrbl = React.lazy(() => import('component/yrbl' /* webpackChunkName: "yrbl" */));
|
||||
|
||||
type Props = {
|
||||
children: Node,
|
||||
history: {
|
||||
|
@ -75,29 +74,27 @@ class ErrorBoundary extends React.Component<Props, State> {
|
|||
if (hasError) {
|
||||
return (
|
||||
<div className="main main--full-width main--empty">
|
||||
<React.Suspense fallback={null}>
|
||||
<Yrbl
|
||||
type="sad"
|
||||
title={__('Aw shucks!')}
|
||||
subtitle={
|
||||
<I18nMessage
|
||||
tokens={{
|
||||
refreshing_the_app_link: (
|
||||
<Button
|
||||
button="link"
|
||||
className="load-screen__button"
|
||||
label={__('refreshing the app')}
|
||||
onClick={this.refresh}
|
||||
/>
|
||||
),
|
||||
}}
|
||||
>
|
||||
There was an error. Try %refreshing_the_app_link% to fix it. If that doesn't work, try pressing
|
||||
Ctrl+R/Cmd+R.
|
||||
</I18nMessage>
|
||||
}
|
||||
/>
|
||||
</React.Suspense>
|
||||
<Yrbl
|
||||
type="sad"
|
||||
title={__('Aw shucks!')}
|
||||
subtitle={
|
||||
<I18nMessage
|
||||
tokens={{
|
||||
refreshing_the_app_link: (
|
||||
<Button
|
||||
button="link"
|
||||
className="load-screen__button"
|
||||
label={__('refreshing the app')}
|
||||
onClick={this.refresh}
|
||||
/>
|
||||
),
|
||||
}}
|
||||
>
|
||||
There was an error. Try %refreshing_the_app_link% to fix it. If that doesn't work, try pressing
|
||||
Ctrl+R/Cmd+R.
|
||||
</I18nMessage>
|
||||
}
|
||||
/>
|
||||
{!errorWasReported && (
|
||||
<div className="error__wrapper">
|
||||
<span className="error__text">
|
||||
|
|
Loading…
Reference in a new issue