Skip to content

Commit

Permalink
WIP fix for vercel#4574: getInitialProps not called during client sid…
Browse files Browse the repository at this point in the history
…e error
  • Loading branch information
jamesreggio committed Jun 22, 2018
1 parent 67cb87a commit e19ec0d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export async function render (props) {
// 404 and 500 errors are special kind of errors
// and they are still handle via the main render method.
export async function renderError (props) {
const {err, errorInfo} = props
const {App, err, errorInfo} = props

// In development we apply sourcemaps to the error
if (process.env.NODE_ENV !== 'production') {
Expand All @@ -162,8 +162,9 @@ export async function renderError (props) {
}

// In production we do a normal render with the `ErrorComponent` as component.
// `App` will handle the calling of `getInitialProps`, which will include the `err` on the context
await doRender({...props, err, Component: ErrorComponent})
// We need to call `getInitialProps` on `App` before mounting.
const initProps = await loadGetInitialProps(App, {Component: ErrorComponent, router, ctx: {err, pathname, query, asPath}})
await doRender({...props, err, Component: ErrorComponent, props: initProps})
}

async function doRender ({ App, Component, props, hash, err, emitter: emitterProp = emitter }) {
Expand Down

0 comments on commit e19ec0d

Please sign in to comment.