Merge pull request #410 from grant-project/chunk-error-refresh

Refresh page on chunk errors
This commit is contained in:
Daniel Ternyak 2019-03-22 19:31:17 -05:00 committed by GitHub
commit bbd9d90350
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 2 deletions

View File

@ -2,21 +2,36 @@ import React from 'react';
import * as Sentry from '@sentry/browser';
import { Button } from 'antd';
import Exception from 'ant-design-pro/lib/Exception';
import Loader from 'components/Loader';
import './index.less';
interface Props {
error: Error;
}
const isChunkError = (err: Error) => {
return err.message.includes('Loading chunk');
};
export default class ErrorScreen extends React.PureComponent<Props> {
componentDidMount() {
const { error } = this.props;
Sentry.captureException(error);
console.error('Error screen showing due to the following error:', error);
if (isChunkError(error)) {
setTimeout(() => {
window.location.reload();
}, 500);
} else {
Sentry.captureException(error);
console.error('Error screen showing due to the following error:', error);
}
}
render() {
const { error } = this.props;
if (isChunkError(error)) {
return <Loader size="large" />;
}
return (
<div className="ErrorScreen">
<Exception