From a4dc93b40a6ece16e67a55c3acf540d1b9c5868a Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Mon, 18 Jan 2021 09:26:36 -0800 Subject: [PATCH 1/2] fix(gatsby): Always render the body component to ensure needed head & pre/post body components are added For client-only pages, we just want to render an empty body but we do want the other components rendered --- .../cache-dir/ssr-develop-static-entry.js | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/packages/gatsby/cache-dir/ssr-develop-static-entry.js b/packages/gatsby/cache-dir/ssr-develop-static-entry.js index c321d307f0539..dcbabb0e948b4 100644 --- a/packages/gatsby/cache-dir/ssr-develop-static-entry.js +++ b/packages/gatsby/cache-dir/ssr-develop-static-entry.js @@ -193,10 +193,22 @@ export default (pagePath, isClientOnlyPage, callback) => { : undefined, } - const pageElement = createElement( - syncRequires.ssrComponents[componentChunkName], - props - ) + let pageElement + if ( + syncRequires.ssrComponents[componentChunkName] && + !isClientOnlyPage + ) { + pageElement = createElement( + syncRequires.ssrComponents[componentChunkName], + props + ) + } else { + // If this is a client-only page or the pageComponent didn't finish + // compiling yet, just render an empty component. + pageElement = () => { + return null + } + } const wrappedPage = apiRunner( `wrapPageElement`, @@ -276,7 +288,7 @@ export default (pagePath, isClientOnlyPage, callback) => { return bodyHtml } - const bodyStr = isClientOnlyPage ? `` : generateBodyHTML() + const bodyStr = generateBodyHTML() const htmlElement = React.createElement(Html, { ...bodyProps, From e759217c5670eaef9e06b7e6110ab3865909f50f Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Mon, 18 Jan 2021 09:43:14 -0800 Subject: [PATCH 2/2] fix lint --- packages/gatsby/cache-dir/ssr-develop-static-entry.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/gatsby/cache-dir/ssr-develop-static-entry.js b/packages/gatsby/cache-dir/ssr-develop-static-entry.js index dcbabb0e948b4..c9e7d6c84bbb8 100644 --- a/packages/gatsby/cache-dir/ssr-develop-static-entry.js +++ b/packages/gatsby/cache-dir/ssr-develop-static-entry.js @@ -205,9 +205,7 @@ export default (pagePath, isClientOnlyPage, callback) => { } else { // If this is a client-only page or the pageComponent didn't finish // compiling yet, just render an empty component. - pageElement = () => { - return null - } + pageElement = () => null } const wrappedPage = apiRunner(