Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make CacheNodeSeedData match FlightRouterState more closely #59590

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const getFlightData = (): FlightData => {
children: ['', {}],
},
],
['about', null, <h1>About Page!</h1>],
['about', {}, <h1>About Page!</h1>],
<>
<title>About page!</title>
</>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('createInitialRouterState', () => {
buildId,
initialTree,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL('/linking', 'https://localhost') as any,
Expand All @@ -47,7 +47,7 @@ describe('createInitialRouterState', () => {
buildId,
initialTree,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL('/linking', 'https://localhost') as any,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const getFlightData = (): FlightData => {
children: ['', {}],
},
],
['about', null, <h1>SubTreeData Injected!</h1>],
['about', {}, <h1>SubTreeData Injected!</h1>],
<>
<title>Head Injected!</title>
</>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const getFlightData = (): FlightData => {
null,
true,
],
['', null, <h1>About Page!</h1>],
['', {}, <h1>About Page!</h1>],
<>
<title>About page!</title>
</>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ export function fillLazyItemsTillLeafWithHead(
// in the response format, so that we don't have to send the keys twice.
// Then the client can convert them into separate representations.
const parallelSeedData =
cacheNodeSeedData !== null &&
cacheNodeSeedData[1] !== null &&
cacheNodeSeedData[1][key] !== undefined
cacheNodeSeedData !== null && cacheNodeSeedData[1][key] !== undefined
? cacheNodeSeedData[1][key]
: null
if (existingCache) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const getFlightData = (): FlightData => {
children: ['', {}],
},
],
['about', null, <h1>About Page!</h1>],
['about', {}, <h1>About Page!</h1>],
<>
<title>About page!</title>
</>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const flightData: FlightData = [
children: ['__PAGE__', {}],
},
],
['about', null, <h1>About Page!</h1>],
['about', {}, <h1>About Page!</h1>],
<>
<title>About page!</title>
</>,
Expand Down Expand Up @@ -58,7 +58,7 @@ const demographicsFlightData: FlightData = [
],
[
'',
null,
{},
<html>
<head></head>
<body>Root layout from response</body>
Expand Down Expand Up @@ -162,7 +162,7 @@ describe('navigateReducer', () => {
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL('/linking', 'https://localhost') as any,
Expand Down Expand Up @@ -355,7 +355,7 @@ describe('navigateReducer', () => {
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL('/linking', 'https://localhost') as any,
Expand Down Expand Up @@ -549,7 +549,7 @@ describe('navigateReducer', () => {
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL('/linking', 'https://localhost') as any,
Expand Down Expand Up @@ -686,7 +686,7 @@ describe('navigateReducer', () => {
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL('/linking', 'https://localhost') as any,
Expand Down Expand Up @@ -823,7 +823,7 @@ describe('navigateReducer', () => {
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL('/linking#hash', 'https://localhost') as any,
Expand Down Expand Up @@ -988,7 +988,7 @@ describe('navigateReducer', () => {
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL('/linking', 'https://localhost') as any,
Expand Down Expand Up @@ -1256,7 +1256,7 @@ describe('navigateReducer', () => {
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL('/parallel-tab-bar', 'https://localhost') as any,
Expand Down Expand Up @@ -1482,7 +1482,7 @@ describe('navigateReducer', () => {
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL('/linking#hash', 'https://localhost') as any,
Expand Down Expand Up @@ -1616,7 +1616,7 @@ describe('navigateReducer', () => {
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL('/linking', 'https://localhost') as any,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jest.mock('../fetch-server-response', () => {
children: ['', {}],
},
],
['about', null, <h1>About Page!</h1>],
['about', {}, <h1>About Page!</h1>],
<>
<title>About page!</title>
</>,
Expand Down Expand Up @@ -116,7 +116,7 @@ describe('prefetchReducer', () => {
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL('/linking', 'https://localhost') as any,
Expand Down Expand Up @@ -258,7 +258,7 @@ describe('prefetchReducer', () => {
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL('/linking', 'https://localhost') as any,
Expand All @@ -269,7 +269,7 @@ describe('prefetchReducer', () => {
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL('/linking', 'https://localhost') as any,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jest.mock('../fetch-server-response', () => {
],
[
'',
null,
{},
<html>
<head></head>
<body>
Expand Down Expand Up @@ -127,7 +127,7 @@ describe('refreshReducer', () => {
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL('/linking', 'https://localhost') as any,
Expand Down Expand Up @@ -270,7 +270,7 @@ describe('refreshReducer', () => {
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL('/linking', 'https://localhost') as any,
Expand All @@ -281,7 +281,7 @@ describe('refreshReducer', () => {
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL('/linking', 'https://localhost') as any,
Expand Down Expand Up @@ -451,7 +451,7 @@ describe('refreshReducer', () => {
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL('/linking', 'https://localhost') as any,
Expand All @@ -462,7 +462,7 @@ describe('refreshReducer', () => {
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL('/linking', 'https://localhost') as any,
Expand Down Expand Up @@ -678,7 +678,7 @@ describe('refreshReducer', () => {
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL('/linking', 'https://localhost') as any,
Expand All @@ -691,7 +691,7 @@ describe('refreshReducer', () => {
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL('/linking', 'https://localhost') as any,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('serverPatchReducer', () => {
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL('/linking', 'https://localhost') as any,
Expand Down Expand Up @@ -238,7 +238,7 @@ describe('serverPatchReducer', () => {
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL('/linking', 'https://localhost') as any,
Expand All @@ -248,7 +248,7 @@ describe('serverPatchReducer', () => {
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL('/linking', 'https://localhost') as any,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jest.mock('../fetch-server-response', () => {
children: ['', {}],
},
],
['about', null, <h1>About Page!</h1>],
['about', {}, <h1>About Page!</h1>],
<>
<title>About page!</title>
</>,
Expand Down Expand Up @@ -56,7 +56,7 @@ const flightDataForPatch: FlightData = [
children: ['', {}],
},
],
['somewhere-else', null, <h1>Somewhere Page!</h1>],
['somewhere-else', {}, <h1>Somewhere Page!</h1>],
<>
<title>Somewhere page!</title>
</>,
Expand Down Expand Up @@ -134,7 +134,7 @@ describe('serverPatchReducer', () => {
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL('/linking/about', 'https://localhost') as any,
Expand Down Expand Up @@ -314,7 +314,7 @@ describe('serverPatchReducer', () => {
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', null, children],
initialSeedData: ['', {}, children],
initialParallelRoutes,
isServer: false,
location: new URL(initialCanonicalUrl, 'https://localhost') as any,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('shouldHardNavigate', () => {
children: ['', {}],
},
],
['about', null, <h1>About Page!</h1>],
['about', {}, <h1>About Page!</h1>],
<>
<title>About page!</title>
</>,
Expand Down Expand Up @@ -94,7 +94,7 @@ describe('shouldHardNavigate', () => {
children: ['', {}],
},
],
[['id', '123', 'd'], null, null],
[['id', '123', 'd'], {}, null],
null,
],
]
Expand Down Expand Up @@ -151,7 +151,7 @@ describe('shouldHardNavigate', () => {
children: ['', {}],
},
],
[['id', '123', 'd'], null, null],
[['id', '123', 'd'], {}, null],
null,
],
]
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server/app-render/app-render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ async function renderToHTMLOrFlightImpl(
// so we create a not found page with AppRouter
const initialSeedData: CacheNodeSeedData = [
initialTree[0],
null,
{},
<html id="__next_error__">
<head></head>
<body></body>
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server/app-render/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export type CacheNodeSeedData = [
segment: Segment,
parallelRoutes: {
[parallelRouterKey: string]: CacheNodeSeedData | null
} | null,
},
node: React.ReactNode | null
]

Expand Down