Skip to content

Commit

Permalink
return null for __DEFAULT__
Browse files Browse the repository at this point in the history
  • Loading branch information
williamli committed Jan 23, 2024
1 parent 193d9d0 commit 6aa0e34
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/next/src/client/components/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '../../shared/lib/hooks-client-context.shared-runtime'
import { clientHookInServerComponentError } from './client-hook-in-server-component-error'
import { getSegmentValue } from './router-reducer/reducers/get-segment-value'
import { PAGE_SEGMENT_KEY } from '../../shared/lib/segment'
import { PAGE_SEGMENT_KEY, DEFAULT_SEGMENT_KEY } from '../../shared/lib/segment'

const INTERNAL_URLSEARCHPARAMS_INSTANCE = Symbol(
'internal for urlsearchparams readonly'
Expand Down Expand Up @@ -242,9 +242,14 @@ export function useSelectedLayoutSegment(
return null
}

return parallelRouteKey === 'children'
? selectedLayoutSegments[0]
: selectedLayoutSegments[selectedLayoutSegments.length - 1] ?? null
const selectedLayoutSegment =
parallelRouteKey === 'children'
? selectedLayoutSegments[0]
: selectedLayoutSegments[selectedLayoutSegments.length - 1] ?? null

return selectedLayoutSegment === DEFAULT_SEGMENT_KEY
? null
: selectedLayoutSegment
}

export { redirect, permanentRedirect, RedirectType } from './redirect'
Expand Down

0 comments on commit 6aa0e34

Please sign in to comment.