From 787a110b75b46f625d135e9f7a22a5f17512d718 Mon Sep 17 00:00:00 2001 From: Arunoda Susiripala Date: Thu, 25 May 2017 21:59:03 +0530 Subject: [PATCH] Fix issue related to 404 and no default exports. (#2063) Just after a 404 page, if we created a page with no default exports. It'll throw an error. And it'll crash internal webpack state. So, once we have it we need to do a hard reload to recover it. --- client/webpack-hot-middleware-client.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/client/webpack-hot-middleware-client.js b/client/webpack-hot-middleware-client.js index f97c5853f7..ac8a7fc045 100644 --- a/client/webpack-hot-middleware-client.js +++ b/client/webpack-hot-middleware-client.js @@ -30,7 +30,16 @@ export default () => { return } - const { err } = Router.components[route] || {} + const { err, Component } = Router.components[route] || {} + + if (!Component) { + // This only happens when we create a new page without a default export. + // If you removed a default export from a exising viewing page, this has no effect. + console.log(`Hard reloading due to no default component in page: ${route}`) + window.location.reload() + return + } + if (err) { // reload to recover from runtime errors Router.reload(route)