Unverified Commit 20600ad2 authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

rsc: remove router injection (#36101)

parent 38d17bca
...@@ -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
......
...@@ -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 />
......
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',
},
}
} }
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,
},
}
} }
...@@ -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 () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment