Skip to content

Commit

Permalink
fix(gatsby): Always render the body component to ensure needed head &…
Browse files Browse the repository at this point in the history
… pre/post body components are added (#29077)

* 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

* fix lint
  • Loading branch information
KyleAMathews committed Jan 18, 2021
1 parent a1921b5 commit e998870
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions packages/gatsby/cache-dir/ssr-develop-static-entry.js
Expand Up @@ -193,10 +193,20 @@ 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 = () => null
}

const wrappedPage = apiRunner(
`wrapPageElement`,
Expand Down Expand Up @@ -276,7 +286,7 @@ export default (pagePath, isClientOnlyPage, callback) => {
return bodyHtml
}

const bodyStr = isClientOnlyPage ? `` : generateBodyHTML()
const bodyStr = generateBodyHTML()

const htmlElement = React.createElement(Html, {
...bodyProps,
Expand Down

0 comments on commit e998870

Please sign in to comment.