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
5c0efcd7
Commit
5c0efcd7
authored
Mar 09, 2026
by
Tim Neutkens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renderLayoutComponent
parent
25c255ca
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
248 additions
and
195 deletions
+248
-195
create-component-tree.tsx
...ages/next/src/server/app-render/create-component-tree.tsx
+248
-195
No files found.
packages/next/src/server/app-render/create-component-tree.tsx
View file @
5c0efcd7
...
@@ -123,10 +123,6 @@ async function createComponentTreeInternal(
...
@@ -123,10 +123,6 @@ async function createComponentTreeInternal(
createElement
,
createElement
,
Fragment
,
Fragment
,
SegmentViewNode
,
SegmentViewNode
,
HTTPAccessFallbackBoundary
,
ClientSegmentRoot
,
createServerParamsForServerSegment
,
createPrerenderParamsForClientSegment
,
serverHooks
:
{
DynamicServerError
},
serverHooks
:
{
DynamicServerError
},
Postpone
,
Postpone
,
},
},
...
@@ -561,18 +557,80 @@ async function createComponentTreeInternal(
...
@@ -561,18 +557,80 @@ async function createComponentTreeInternal(
isPossiblyPartialResponse
isPossiblyPartialResponse
)
)
}
else
{
}
else
{
const
SegmentComponent
=
Component
return
renderLayoutComponent
(
const
isRootLayoutWithChildrenSlotAndAtLeastOneMoreSlot
=
ctx
,
Component
,
isClientComponent
,
rootLayoutAtThisLevel
&&
rootLayoutAtThisLevel
&&
'children'
in
parallelRoutes
&&
'children'
in
parallelRoutes
&&
Object
.
keys
(
parallelRoutes
).
length
>
1
Object
.
keys
(
parallelRoutes
).
length
>
1
,
currentParams
,
parallelRouteProps
,
optionalCatchAllParamName
,
varyParamsAccumulator
,
isRuntimePrefetchable
,
NotFound
,
Forbidden
,
Unauthorized
,
notFoundElement
,
forbiddenElement
,
unauthorizedElement
,
notFoundStyles
,
layerAssets
,
tree
,
dir
,
isSegmentViewEnabled
,
parallelRouteCacheNodeSeedData
,
loadingData
,
isPossiblyPartialResponse
)
}
}
function
renderLayoutComponent
(
ctx
:
AppRenderContext
,
SegmentComponent
:
ComponentType
<
any
>
,
isClientComponent
:
boolean
,
isRootLayoutWithChildrenSlotAndAtLeastOneMoreSlot
:
boolean
,
currentParams
:
Params
,
parallelRouteProps
:
{
[
key
:
string
]:
React
.
ReactNode
},
optionalCatchAllParamName
:
string
|
null
,
varyParamsAccumulator
:
VaryParamsAccumulator
|
null
,
isRuntimePrefetchable
:
boolean
,
NotFound
:
ComponentType
<
any
>
|
undefined
,
Forbidden
:
ComponentType
<
any
>
|
undefined
,
Unauthorized
:
ComponentType
<
any
>
|
undefined
,
notFoundElement
:
React
.
ReactNode
|
undefined
,
forbiddenElement
:
React
.
ReactNode
|
undefined
,
unauthorizedElement
:
React
.
ReactNode
|
undefined
,
notFoundStyles
:
React
.
ReactNode
|
undefined
,
layerAssets
:
React
.
ReactNode
,
tree
:
LoaderTree
,
dir
:
string
,
isSegmentViewEnabled
:
boolean
,
parallelRouteCacheNodeSeedData
:
Record
<
string
,
CacheNodeSeedData
|
null
>
,
loadingData
:
LoadingModuleData
,
isPossiblyPartialResponse
:
boolean
):
CacheNodeSeedData
{
const
{
renderOpts
:
{
cacheComponents
},
workStore
:
{
isStaticGeneration
},
componentMod
:
{
createElement
,
Fragment
,
SegmentViewNode
,
HTTPAccessFallbackBoundary
,
ClientSegmentRoot
,
createServerParamsForServerSegment
,
createPrerenderParamsForClientSegment
,
},
}
=
ctx
let
segmentNode
:
React
.
ReactNode
let
segmentNode
:
React
.
ReactNode
if
(
isClientComponent
)
{
if
(
isClientComponent
)
{
let
clientSegment
:
React
.
ReactNode
let
clientSegment
:
React
.
ReactNode
if
(
cacheComponents
)
{
if
(
cacheComponents
)
{
// Params are omitted when Cache Components is enabled
clientSegment
=
createElement
(
ClientSegmentRoot
,
{
clientSegment
=
createElement
(
ClientSegmentRoot
,
{
Component
:
SegmentComponent
,
Component
:
SegmentComponent
,
slots
:
parallelRouteProps
,
slots
:
parallelRouteProps
,
...
@@ -602,15 +660,12 @@ async function createComponentTreeInternal(
...
@@ -602,15 +660,12 @@ async function createComponentTreeInternal(
}
}
if
(
isRootLayoutWithChildrenSlotAndAtLeastOneMoreSlot
)
{
if
(
isRootLayoutWithChildrenSlotAndAtLeastOneMoreSlot
)
{
let
notfoundClientSegment
:
React
.
ReactNode
let
forbiddenClientSegment
:
React
.
ReactNode
let
unauthorizedClientSegment
:
React
.
ReactNode
// TODO-APP: This is a hack to support unmatched parallel routes, which will throw `notFound()`.
// TODO-APP: This is a hack to support unmatched parallel routes, which will throw `notFound()`.
// This ensures that a `HTTPAccessFallbackBoundary` is available for when that happens,
// This ensures that a `HTTPAccessFallbackBoundary` is available for when that happens,
// but it's not ideal, as it needlessly invokes the `NotFound` component and renders the `RootLayout` twice.
// but it's not ideal, as it needlessly invokes the `NotFound` component and renders the `RootLayout` twice.
// We should instead look into handling the fallback behavior differently in development mode so that it doesn't
// We should instead look into handling the fallback behavior differently in development mode so that it doesn't
// rely on the `NotFound` behavior.
// rely on the `NotFound` behavior.
notfoundClientSegment
=
createErrorBoundaryClientSegmentRoot
({
const
notfoundClientSegment
=
createErrorBoundaryClientSegmentRoot
({
ctx
,
ctx
,
ErrorBoundaryComponent
:
NotFound
,
ErrorBoundaryComponent
:
NotFound
,
errorElement
:
notFoundElement
,
errorElement
:
notFoundElement
,
...
@@ -619,7 +674,7 @@ async function createComponentTreeInternal(
...
@@ -619,7 +674,7 @@ async function createComponentTreeInternal(
SegmentComponent
,
SegmentComponent
,
currentParams
,
currentParams
,
})
})
forbiddenClientSegment
=
createErrorBoundaryClientSegmentRoot
({
const
forbiddenClientSegment
=
createErrorBoundaryClientSegmentRoot
({
ctx
,
ctx
,
ErrorBoundaryComponent
:
Forbidden
,
ErrorBoundaryComponent
:
Forbidden
,
errorElement
:
forbiddenElement
,
errorElement
:
forbiddenElement
,
...
@@ -628,7 +683,7 @@ async function createComponentTreeInternal(
...
@@ -628,7 +683,7 @@ async function createComponentTreeInternal(
SegmentComponent
,
SegmentComponent
,
currentParams
,
currentParams
,
})
})
unauthorizedClientSegment
=
createErrorBoundaryClientSegmentRoot
({
const
unauthorizedClientSegment
=
createErrorBoundaryClientSegmentRoot
({
ctx
,
ctx
,
ErrorBoundaryComponent
:
Unauthorized
,
ErrorBoundaryComponent
:
Unauthorized
,
errorElement
:
unauthorizedElement
,
errorElement
:
unauthorizedElement
,
...
@@ -766,7 +821,6 @@ async function createComponentTreeInternal(
...
@@ -766,7 +821,6 @@ async function createComponentTreeInternal(
)
)
:
segmentNode
:
segmentNode
// For layouts we just render the component
return
createSeedData
(
return
createSeedData
(
ctx
,
ctx
,
wrappedSegmentNode
,
wrappedSegmentNode
,
...
@@ -777,7 +831,6 @@ async function createComponentTreeInternal(
...
@@ -777,7 +831,6 @@ async function createComponentTreeInternal(
varyParamsAccumulator
varyParamsAccumulator
)
)
}
}
}
function
renderPageComponent
(
function
renderPageComponent
(
...
...
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