Skip to content

Commit

Permalink
Move root div to an app wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
devknoll committed Nov 19, 2021
1 parent d1ce7b7 commit 3eb161c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 2 additions & 5 deletions packages/next/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -766,13 +766,10 @@ export function Main({
}: {
children?: (content: JSX.Element) => JSX.Element
}) {
const { inAmpMode, docComponentsRendered, useMainContent } =
useContext(HtmlContext)
const { docComponentsRendered, useMainContent } = useContext(HtmlContext)
const content = useMainContent(children)
docComponentsRendered.Main = true

if (inAmpMode) return content
return <div id="__next">{content}</div>
return content
}

export class NextScript extends Component<OriginProps> {
Expand Down
7 changes: 5 additions & 2 deletions packages/next/server/render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1041,14 +1041,17 @@ export async function renderToHTML(
}
}

const appWrappers: Array<(content: JSX.Element) => JSX.Element> = []
const appWrappers: Array<(content: JSX.Element) => JSX.Element> = [
(content) =>
inAmpMode ? <>{content}</> : <div id="__next">{content}</div>,
]
const getWrappedApp = (app: JSX.Element) => {
// Prevent wrappers from reading/writing props by rendering inside an
// opaque component. Wrappers should use context instead.
const InnerApp = () => app
return (
<AppContainerWithIsomorphicFiberStructure>
{appWrappers.reduce((innerContent, fn) => {
{appWrappers.reduceRight((innerContent, fn) => {
return fn(innerContent)
}, <InnerApp />)}
</AppContainerWithIsomorphicFiberStructure>
Expand Down

0 comments on commit 3eb161c

Please sign in to comment.