fix: Failed editor chunk load should refresh page

This commit is contained in:
Tom Moor 2020-04-06 08:50:43 -07:00
parent 1a60f51460
commit c94823dd59
1 changed files with 11 additions and 3 deletions

View File

@ -151,9 +151,17 @@ class DocumentScene extends React.Component<Props> {
loadEditor = async () => {
if (this.editorComponent) return;
const Imported = await import('./Editor');
EditorImport = Imported.default;
this.editorComponent = EditorImport;
try {
const EditorImport = await import('./Editor');
this.editorComponent = EditorImport.default;
} catch (err) {
console.error(err);
// If the editor bundle fails to load then reload the entire window. This
// can happen if a deploy happens between the user loading the initial JS
// bundle and the async-loaded editor JS bundle as the hash will change.
window.location.reload();
}
};
handleCloseMoveModal = () => (this.moveModalOpen = false);