Skip to content

Commit

Permalink
handle no doc gip case
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Mar 30, 2022
1 parent 04ff525 commit 8daae43
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions packages/next/server/render.tsx
Expand Up @@ -1431,10 +1431,15 @@ export async function renderToHTML(
})
}

const documentInitialPropsRes =
isServerComponent || process.browser || !Document.getInitialProps
? {}
: await documentInitialProps()
const hasDocumentGetInitialProps = !(
isServerComponent ||
process.browser ||
!Document.getInitialProps
)

const documentInitialPropsRes = hasDocumentGetInitialProps
? await documentInitialProps()
: {}
if (documentInitialPropsRes === null) return null

const { docProps } = (documentInitialPropsRes as any) || {}
Expand All @@ -1445,13 +1450,21 @@ export async function renderToHTML(

return <Document {...htmlProps} {...docProps} />
}
let styles

if (hasDocumentGetInitialProps) {
styles = docProps.styles
} else {
styles = jsxStyleRegistry.styles()
jsxStyleRegistry.flush()
}

return {
bodyResult,
documentElement,
head,
headTags: [],
styles: docProps.styles,
styles,
}
}
}
Expand Down

0 comments on commit 8daae43

Please sign in to comment.