diff --git a/packages/next/pages/_document.tsx b/packages/next/pages/_document.tsx
index cac934af2801bcc..c1c00608dc5fb65 100644
--- a/packages/next/pages/_document.tsx
+++ b/packages/next/pages/_document.tsx
@@ -756,15 +756,11 @@ export class Head extends Component<
}
}
-export function Main({
- children,
-}: {
- children?: (content: JSX.Element) => JSX.Element
-}) {
- const { docComponentsRendered, useMainContent } = useContext(HtmlContext)
- const content = useMainContent(children)
+export function Main() {
+ const { docComponentsRendered } = useContext(HtmlContext)
docComponentsRendered.Main = true
- return content
+ // @ts-ignore
+ return
}
export class NextScript extends Component {
diff --git a/packages/next/server/render.tsx b/packages/next/server/render.tsx
index 00d6546ec15a2f2..f5b30f9b5d77545 100644
--- a/packages/next/server/render.tsx
+++ b/packages/next/server/render.tsx
@@ -1048,20 +1048,6 @@ export async function renderToHTML(
return inAmpMode ? children : {children}
}
- const appWrappers: Array<(content: JSX.Element) => JSX.Element> = []
- 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 (
-
- {appWrappers.reduceRight((innerContent, fn) => {
- return fn(innerContent)
- }, )}
-
- )
- }
-
/**
* Rules of Static & Dynamic HTML:
*
@@ -1106,13 +1092,13 @@ export async function renderToHTML(
const html = ReactDOMServer.renderToString(
- {getWrappedApp(
+
- )}
+
)
return { html, head }
@@ -1137,15 +1123,6 @@ export async function renderToHTML(
documentElement: (htmlProps: HtmlProps) => (
),
- useMainContent: (fn?: (content: JSX.Element) => JSX.Element) => {
- if (fn) {
- throw new Error(
- 'The `children` property is not supported by non-functional custom Document components'
- )
- }
- // @ts-ignore
- return
- },
head: docProps.head,
headTags: await headTags(documentCtx),
styles: docProps.styles,
@@ -1164,9 +1141,9 @@ export async function renderToHTML(
- {getWrappedApp(
+
- )}
+
- {getWrappedApp(
+
- )}
+
-
- {(children) => (
-
- {children}
-
- )}
-
-
-
-
- )
-}
diff --git a/test/integration/document-functional-render-prop/app/pages/index.js b/test/integration/document-functional-render-prop/app/pages/index.js
deleted file mode 100644
index d00fe7fc70a6b5d..000000000000000
--- a/test/integration/document-functional-render-prop/app/pages/index.js
+++ /dev/null
@@ -1,7 +0,0 @@
-import { useContext } from 'react'
-import Context from '../lib/context'
-
-export default function MainRenderProp() {
- const value = useContext(Context)
- return {value}
-}
diff --git a/test/integration/document-functional-render-prop/tests/index.test.js b/test/integration/document-functional-render-prop/tests/index.test.js
deleted file mode 100644
index c843082feed935e..000000000000000
--- a/test/integration/document-functional-render-prop/tests/index.test.js
+++ /dev/null
@@ -1,25 +0,0 @@
-/* eslint-env jest */
-
-import { join } from 'path'
-import { findPort, launchApp, killApp, renderViaHTTP } from 'next-test-utils'
-
-const nodeArgs = ['-r', join(__dirname, '../../react-18/test/require-hook.js')]
-const appDir = join(__dirname, '../app')
-let appPort
-let app
-
-describe('Functional Custom Document', () => {
- describe('development mode', () => {
- beforeAll(async () => {
- appPort = await findPort()
- app = await launchApp(appDir, appPort, { nodeArgs })
- })
-
- afterAll(() => killApp(app))
-
- it('supports render props', async () => {
- const html = await renderViaHTTP(appPort, '/')
- expect(html).toMatch(/from render prop<\/span>/)
- })
- })
-})