Skip to content

Commit a4aa1df

Browse files
authored
rsc: keep static page props (#36157)
1 parent be3c804 commit a4aa1df

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

packages/next/server/render.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -431,14 +431,7 @@ function createServerComponentRenderer(
431431
return root
432432
}
433433

434-
// Although it's not allowed to attach some static methods to Component,
435-
// we still re-assign all the component APIs to keep the behavior unchanged.
436-
for (const methodName of [
437-
'getInitialProps',
438-
'getStaticProps',
439-
'getServerSideProps',
440-
'getStaticPaths',
441-
]) {
434+
for (const methodName of Object.keys(Component)) {
442435
const method = (Component as any)[methodName]
443436
if (method) {
444437
;(ServerComponentWrapper as any)[methodName] = method
@@ -1375,7 +1368,7 @@ export async function renderToHTML(
13751368
<AppContainerWithIsomorphicFiberStructure>
13761369
{isServerComponent && !!AppMod.__next_rsc__ ? (
13771370
// _app.server.js is used.
1378-
<Component {...props.pageProps} router={router} />
1371+
<Component {...props.pageProps} />
13791372
) : (
13801373
<App {...props} Component={Component} router={router} />
13811374
)}

test/integration/react-streaming-and-server-components/switchable-runtime/pages/_app.server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default function AppServer({ children }) {
22
return (
3-
<div className="app-server-root">
3+
<div className="app-server-root" data-title={children.type.title || ''}>
44
<style>{`.app-server-root { border: 2px solid blue; }`}</style>
55
{children}
66
</div>

test/integration/react-streaming-and-server-components/switchable-runtime/pages/node-rsc.server.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export default function Page() {
1313
)
1414
}
1515

16+
Page.title = 'node-rsc'
17+
1618
export const config = {
1719
runtime: 'nodejs',
1820
}

test/integration/react-streaming-and-server-components/test/switchable-runtime.test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ async function testRoute(appPort, url, { isStatic, isEdge, isRSC }) {
3838
// Should be re-rendered.
3939
expect(renderedAt1).toBeLessThan(renderedAt2)
4040
}
41-
const customAppServerHtml = '<div class="app-server-root">'
41+
const customAppServerHtml = '<div class="app-server-root"'
4242
if (isRSC) {
4343
expect(html1).toContain(customAppServerHtml)
4444
} else {
@@ -101,6 +101,9 @@ describe('Switchable runtime (prod)', () => {
101101
isEdge: false,
102102
isRSC: true,
103103
})
104+
105+
const html = await renderViaHTTP(context.appPort, '/node-rsc')
106+
expect(html).toContain('data-title="node-rsc"')
104107
})
105108

106109
it('should build /node-rsc-ssr as a dynamic page with the nodejs runtime', async () => {

0 commit comments

Comments
 (0)