Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rsc: keep static page props #36157

Merged
merged 1 commit into from Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 2 additions & 9 deletions packages/next/server/render.tsx
Expand Up @@ -431,14 +431,7 @@ function createServerComponentRenderer(
return root
}

// Although it's not allowed to attach some static methods to Component,
// we still re-assign all the component APIs to keep the behavior unchanged.
for (const methodName of [
'getInitialProps',
'getStaticProps',
'getServerSideProps',
'getStaticPaths',
]) {
for (const methodName of Object.keys(Component)) {
const method = (Component as any)[methodName]
if (method) {
;(ServerComponentWrapper as any)[methodName] = method
Expand Down Expand Up @@ -1375,7 +1368,7 @@ export async function renderToHTML(
<AppContainerWithIsomorphicFiberStructure>
{isServerComponent && !!AppMod.__next_rsc__ ? (
// _app.server.js is used.
<Component {...props.pageProps} router={router} />
<Component {...props.pageProps} />
) : (
<App {...props} Component={Component} router={router} />
)}
Expand Down
@@ -1,6 +1,6 @@
export default function AppServer({ children }) {
return (
<div className="app-server-root">
<div className="app-server-root" data-title={children.type.title || ''}>
<style>{`.app-server-root { border: 2px solid blue; }`}</style>
{children}
</div>
Expand Down
Expand Up @@ -13,6 +13,8 @@ export default function Page() {
)
}

Page.title = 'node-rsc'

export const config = {
runtime: 'nodejs',
}
Expand Up @@ -38,7 +38,7 @@ async function testRoute(appPort, url, { isStatic, isEdge, isRSC }) {
// Should be re-rendered.
expect(renderedAt1).toBeLessThan(renderedAt2)
}
const customAppServerHtml = '<div class="app-server-root">'
const customAppServerHtml = '<div class="app-server-root"'
if (isRSC) {
expect(html1).toContain(customAppServerHtml)
} else {
Expand Down Expand Up @@ -101,6 +101,9 @@ describe('Switchable runtime (prod)', () => {
isEdge: false,
isRSC: true,
})

const html = await renderViaHTTP(context.appPort, '/node-rsc')
expect(html).toContain('data-title="node-rsc"')
})

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