-
Notifications
You must be signed in to change notification settings - Fork 27.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure root layout only render once per request (#52589)
Introduce a new way to search for `not-found` component that based on the request pathname and current loader tree of that route. And we search the proper not-found in the finall catch closure of app rendering, so that we don't have to pass down the root layout to app-router to create the extra error boundary. This ensures the root layout doesn't have duplicated rendering for normal requests Fixes NEXT-1220 Fixes #49115
- Loading branch information
Showing
9 changed files
with
150 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react' | ||
|
||
export const revalidate = 0 | ||
|
||
let value = 0 | ||
export default function Layout({ children }) { | ||
return ( | ||
<html> | ||
<head></head> | ||
<body> | ||
<div id="render-once">{children}</div> | ||
<p id="counter">{value++}</p> | ||
</body> | ||
</html> | ||
) | ||
} |
3 changes: 3 additions & 0 deletions
3
test/e2e/app-dir/root-layout-render-once/app/render-once/page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function page() { | ||
return 'render-once' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { createNextDescribe } from 'e2e-utils' | ||
|
||
createNextDescribe( | ||
'app-dir root layout render once', | ||
{ | ||
files: __dirname, | ||
skipDeployment: true, | ||
}, | ||
({ next }) => { | ||
it('should only render root layout once', async () => { | ||
let $ = await next.render$('/render-once') | ||
expect($('#counter').text()).toBe('0') | ||
$ = await next.render$('/render-once') | ||
expect($('#counter').text()).toBe('1') | ||
$ = await next.render$('/render-once') | ||
expect($('#counter').text()).toBe('2') | ||
}) | ||
} | ||
) |
This file was deleted.
Oops, something went wrong.