Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
a4aa1df7
Unverified
Commit
a4aa1df7
authored
Apr 14, 2022
by
Jiachi Liu
Committed by
GitHub
Apr 14, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rsc: keep static page props (#36157)
parent
be3c804b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
11 deletions
+9
-11
render.tsx
packages/next/server/render.tsx
+2
-9
_app.server.js
...server-components/switchable-runtime/pages/_app.server.js
+1
-1
node-rsc.server.js
...er-components/switchable-runtime/pages/node-rsc.server.js
+2
-0
switchable-runtime.test.js
...ing-and-server-components/test/switchable-runtime.test.js
+4
-1
No files found.
packages/next/server/render.tsx
View file @
a4aa1df7
...
...
@@ -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
...
...
@@ -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
}
/>
)
}
...
...
test/integration/react-streaming-and-server-components/switchable-runtime/pages/_app.server.js
View file @
a4aa1df7
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
>
...
...
test/integration/react-streaming-and-server-components/switchable-runtime/pages/node-rsc.server.js
View file @
a4aa1df7
...
...
@@ -13,6 +13,8 @@ export default function Page() {
)
}
Page
.
title
=
'node-rsc'
export
const
config
=
{
runtime
:
'nodejs'
,
}
test/integration/react-streaming-and-server-components/test/switchable-runtime.test.js
View file @
a4aa1df7
...
...
@@ -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
{
...
...
@@ -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
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment