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

refactor: remove unnecessary page segment check in ppr-navigations #70572

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import type {
ChildSegmentMap,
ReadyCacheNode,
} from '../../../shared/lib/app-router-context.shared-runtime'
import {
DEFAULT_SEGMENT_KEY,
PAGE_SEGMENT_KEY,
} from '../../../shared/lib/segment'
import { DEFAULT_SEGMENT_KEY } from '../../../shared/lib/segment'
import { matchSegment } from '../match-segments'
import { createRouterCacheKey } from './create-router-cache-key'
import type { FetchServerResponseResult } from './fetch-server-response'
Expand Down Expand Up @@ -124,27 +121,13 @@ export function updateCacheNodeOnNavigation(
const oldSegmentChild =
oldRouterStateChild !== undefined ? oldRouterStateChild[0] : undefined

// A dynamic segment will be an array, and doesn't correspond with a page segment.
const isPageSegment = Array.isArray(newSegmentChild)
? false
: // A page segment might contain search parameters, so we verify that it starts with the page segment key.
newSegmentChild.startsWith(PAGE_SEGMENT_KEY)

const oldCacheNodeChild =
oldSegmentMapChild !== undefined
? oldSegmentMapChild.get(newSegmentKeyChild)
: undefined

let taskChild: Task | null
if (isPageSegment) {
// This is a leaf segment — a page, not a shared layout. We always apply
// its data.
taskChild = spawnPendingTask(
newRouterStateChild,
prefetchDataChild !== undefined ? prefetchDataChild : null,
prefetchHead
)
} else if (newSegmentChild === DEFAULT_SEGMENT_KEY) {
if (newSegmentChild === DEFAULT_SEGMENT_KEY) {
// This is another kind of leaf segment — a default route.
//
// Default routes have special behavior. When there's no matching segment
Expand Down
Loading