feat: Add custom error state for chunk loading failed
This commit is contained in:
@ -55,7 +55,26 @@ class ErrorBoundary extends React.Component<Props> {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (this.error) {
|
if (this.error) {
|
||||||
|
const error = this.error;
|
||||||
const isReported = !!window.Sentry && env.DEPLOYMENT === "hosted";
|
const isReported = !!window.Sentry && env.DEPLOYMENT === "hosted";
|
||||||
|
const isChunkError = this.error.message.match(/chunk/);
|
||||||
|
|
||||||
|
if (isChunkError) {
|
||||||
|
return (
|
||||||
|
<CenteredContent>
|
||||||
|
<PageTitle title="Module failed to load" />
|
||||||
|
<h1>Loading Failed</h1>
|
||||||
|
<HelpText>
|
||||||
|
Sorry, part of the application failed to load. This may be because
|
||||||
|
it was updated since you opened the tab or because of a failed
|
||||||
|
network request. Please try reloading.
|
||||||
|
</HelpText>
|
||||||
|
<p>
|
||||||
|
<Button onClick={this.handleReload}>Reload</Button>
|
||||||
|
</p>
|
||||||
|
</CenteredContent>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CenteredContent>
|
<CenteredContent>
|
||||||
@ -66,7 +85,7 @@ class ErrorBoundary extends React.Component<Props> {
|
|||||||
{isReported && " – our engineers have been notified"}. Please try
|
{isReported && " – our engineers have been notified"}. Please try
|
||||||
reloading the page, it may have been a temporary glitch.
|
reloading the page, it may have been a temporary glitch.
|
||||||
</HelpText>
|
</HelpText>
|
||||||
{this.showDetails && <Pre>{this.error.toString()}</Pre>}
|
{this.showDetails && <Pre>{error.toString()}</Pre>}
|
||||||
<p>
|
<p>
|
||||||
<Button onClick={this.handleReload}>Reload</Button>{" "}
|
<Button onClick={this.handleReload}>Reload</Button>{" "}
|
||||||
{this.showDetails ? (
|
{this.showDetails ? (
|
||||||
|
Reference in New Issue
Block a user