Skip to content

Commit f5917ad

Browse files
authored
Fix server component render condition (#35663)
We are currently using `!!ComponentMod.__next_rsc__` as the hint for the renderer to tell if the component is a server component, however that export field (`__next_rsc__`) is assigned to client components (`.client.[ext]`) as well. This PR adds a new `__next_rsc_server__` field which is only true when the component is a server component so the renderer can handle client components correctly. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint`
1 parent 41a2eb2 commit f5917ad

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

packages/next/build/webpack/loaders/next-flight-server-loader.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ export default async function transformSource(
186186
__webpack_require__,
187187
_: () => {\n${imports}\n}
188188
}`,
189+
__next_rsc_server__: isServerComponent(resourcePath) ? 'true' : 'false',
189190
}
190191

191192
if (isClientCompilation) {

packages/next/server/render.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,9 @@ export async function renderToHTML(
469469

470470
// We don't need to opt-into the flight inlining logic if the page isn't a RSC.
471471
const isServerComponent =
472-
!!serverComponentManifest &&
473472
hasConcurrentFeatures &&
474-
!!ComponentMod.__next_rsc__
473+
!!serverComponentManifest &&
474+
!!ComponentMod.__next_rsc_server__
475475

476476
let Component: React.ComponentType<{}> | ((props: any) => JSX.Element) =
477477
renderOpts.Component

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy