From e19ec0dab03ba86c51c11b9a491bf3e43657966d Mon Sep 17 00:00:00 2001 From: James Reggio Date: Thu, 21 Jun 2018 21:15:04 -0400 Subject: [PATCH] WIP fix for #4574: getInitialProps not called during client side error --- client/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/index.js b/client/index.js index 57d3bdfce50dd..3c847c75c1de4 100644 --- a/client/index.js +++ b/client/index.js @@ -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') { @@ -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 }) {