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
20600ad2
Unverified
Commit
20600ad2
authored
Apr 13, 2022
by
Jiachi Liu
Committed by
GitHub
Apr 13, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rsc: remove router injection (#36101)
parent
38d17bca
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
14 deletions
+19
-14
render.tsx
packages/next/server/render.tsx
+2
-2
index.server.js
...streaming-and-server-components/app/pages/index.server.js
+1
-2
link.server.js
...g-and-server-components/app/pages/next-api/link.server.js
+8
-5
[dynamic].server.js
...nd-server-components/app/pages/routes/[dynamic].server.js
+8
-4
rsc.js
...gration/react-streaming-and-server-components/test/rsc.js
+0
-1
No files found.
packages/next/server/render.tsx
View file @
20600ad2
...
@@ -741,7 +741,7 @@ export async function renderToHTML(
...
@@ -741,7 +741,7 @@ export async function renderToHTML(
AppTree
:
(
props
:
any
)
=>
{
AppTree
:
(
props
:
any
)
=>
{
return
(
return
(
<
AppContainerWithIsomorphicFiberStructure
>
<
AppContainerWithIsomorphicFiberStructure
>
{
renderFlight
(
AppMod
,
ComponentMod
,
{
...
props
,
router
}
)
}
{
renderFlight
(
AppMod
,
ComponentMod
,
props
)
}
</
AppContainerWithIsomorphicFiberStructure
>
</
AppContainerWithIsomorphicFiberStructure
>
)
)
},
},
...
@@ -1216,7 +1216,7 @@ export async function renderToHTML(
...
@@ -1216,7 +1216,7 @@ export async function renderToHTML(
// Pass router to the Server Component as a temporary workaround.
// Pass router to the Server Component as a temporary workaround.
if
(
isServerComponent
)
{
if
(
isServerComponent
)
{
props
.
pageProps
=
Object
.
assign
({},
props
.
pageProps
,
{
router
}
)
props
.
pageProps
=
Object
.
assign
({},
props
.
pageProps
)
}
}
// the response might be finished on the getInitialProps call
// the response might be finished on the getInitialProps call
...
...
test/integration/react-streaming-and-server-components/app/pages/index.server.js
View file @
20600ad2
...
@@ -3,11 +3,10 @@ import Nav from '../components/nav'
...
@@ -3,11 +3,10 @@ import Nav from '../components/nav'
const
envVar
=
process
.
env
.
ENV_VAR_TEST
const
envVar
=
process
.
env
.
ENV_VAR_TEST
const
headerKey
=
'x-next-test-client'
const
headerKey
=
'x-next-test-client'
export
default
function
Index
({
header
,
router
})
{
export
default
function
Index
({
header
})
{
return
(
return
(
<
div
>
<
div
>
<
h1
>
{
`component:index.server`
}
<
/h1
>
<
h1
>
{
`component:index.server`
}
<
/h1
>
<
div
>
{
'path:'
+
router
.
pathname
}
<
/div
>
<
div
>
{
'env:'
+
envVar
}
<
/div
>
<
div
>
{
'env:'
+
envVar
}
<
/div
>
<
div
>
{
'header:'
+
header
}
<
/div
>
<
div
>
{
'header:'
+
header
}
<
/div
>
<
Nav
/>
<
Nav
/>
...
...
test/integration/react-streaming-and-server-components/app/pages/next-api/link.server.js
View file @
20600ad2
import
Link
from
'next/link'
import
Link
from
'next/link'
import
Nav
from
'../../components/nav'
import
Nav
from
'../../components/nav'
export
default
function
LinkPage
({
router
})
{
export
default
function
LinkPage
({
queryId
})
{
const
{
query
}
=
router
const
id
=
parseInt
(
queryId
)
const
id
=
parseInt
(
query
.
id
||
'0'
,
10
)
return
(
return
(
<>
<>
<
h3
id
=
"query"
>
query
:{
id
}
<
/h3
>
<
h3
id
=
"query"
>
query
:{
id
}
<
/h3
>
...
@@ -17,6 +16,10 @@ export default function LinkPage({ router }) {
...
@@ -17,6 +16,10 @@ export default function LinkPage({ router }) {
)
)
}
}
export
const
config
=
{
export
function
getServerSideProps
({
query
})
{
runtime
:
'edge'
,
return
{
props
:
{
queryId
:
query
.
id
||
'0'
,
},
}
}
}
test/integration/react-streaming-and-server-components/app/pages/routes/[dynamic].server.js
View file @
20600ad2
export
default
function
Pid
({
router
})
{
export
default
function
Pid
({
text
})
{
return
<
div
>
{
`query:
${
router
.
query
.
dynamic
}
`
}
<
/div
>
return
<
div
>
{
`query:
${
text
}
`
}
<
/div
>
}
}
export
const
config
=
{
export
function
getServerSideProps
({
params
})
{
runtime
:
'edge'
,
return
{
props
:
{
text
:
params
.
dynamic
,
},
}
}
}
test/integration/react-streaming-and-server-components/test/rsc.js
View file @
20600ad2
...
@@ -19,7 +19,6 @@ export default function (context, { runtime, env }) {
...
@@ -19,7 +19,6 @@ export default function (context, { runtime, env }) {
expect
(
homeHTML
).
toContain
(
'component:index.server'
)
expect
(
homeHTML
).
toContain
(
'component:index.server'
)
expect
(
homeHTML
).
toContain
(
'env:env_var_test'
)
expect
(
homeHTML
).
toContain
(
'env:env_var_test'
)
expect
(
homeHTML
).
toContain
(
'header:test-util'
)
expect
(
homeHTML
).
toContain
(
'header:test-util'
)
expect
(
homeHTML
).
toContain
(
'path:/'
)
})
})
it
(
'should reuse the inline flight response without sending extra requests'
,
async
()
=>
{
it
(
'should reuse the inline flight response without sending extra requests'
,
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