Skip to content

Commit

Permalink
Fix issue related to 404 and no default exports. (vercel#2063)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
arunoda authored and xuezhma committed Jun 22, 2017
1 parent 80c4d63 commit 242bb38
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion client/webpack-hot-middleware-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 242bb38

Please sign in to comment.