Skip to content

Commit

Permalink
rsc: remove router injection
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Apr 12, 2022
1 parent 46d3f0e commit 65eed19
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/next/server/render.tsx
Expand Up @@ -741,7 +741,7 @@ export async function renderToHTML(
AppTree: (props: any) => {
return (
<AppContainerWithIsomorphicFiberStructure>
{renderFlight(AppMod, ComponentMod, { ...props, router })}
{renderFlight(AppMod, ComponentMod, props)}
</AppContainerWithIsomorphicFiberStructure>
)
},
Expand Down Expand Up @@ -1216,7 +1216,7 @@ export async function renderToHTML(

// Pass router to the Server Component as a temporary workaround.
if (isServerComponent) {
props.pageProps = Object.assign({}, props.pageProps, { router })
props.pageProps = Object.assign({}, props.pageProps)
}

// the response might be finished on the getInitialProps call
Expand Down
Expand Up @@ -3,11 +3,10 @@ import Nav from '../components/nav'
const envVar = process.env.ENV_VAR_TEST
const headerKey = 'x-next-test-client'

export default function Index({ header, router }) {
export default function Index({ header }) {
return (
<div>
<h1>{`component:index.server`}</h1>
<div>{'path:' + router.pathname}</div>
<div>{'env:' + envVar}</div>
<div>{'header:' + header}</div>
<Nav />
Expand Down
Expand Up @@ -19,7 +19,6 @@ export default function (context, { runtime, env }) {
expect(homeHTML).toContain('component:index.server')
expect(homeHTML).toContain('env:env_var_test')
expect(homeHTML).toContain('header:test-util')
expect(homeHTML).toContain('path:/')
})

it('should reuse the inline flight response without sending extra requests', async () => {
Expand Down

0 comments on commit 65eed19

Please sign in to comment.