-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
useSelectedLayoutSegment at the current level (#42299)
When `useSelectedLayoutSegment` is used on the current level or in a page it should return null. fixes #41879 fixes #41878 ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
- Loading branch information
Hannes Bornö
authored
Nov 2, 2022
1 parent
9de871e
commit 8350f7e
Showing
5 changed files
with
61 additions
and
12 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
13 changes: 10 additions & 3 deletions
13
...pp/hooks/use-selected-layout-segment/first/[dynamic]/(group)/second/[...catchall]/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 |
---|---|---|
@@ -1,11 +1,18 @@ | ||
'use client' | ||
|
||
import { useSelectedLayoutSegments } from 'next/navigation' | ||
import { | ||
useSelectedLayoutSegments, | ||
useSelectedLayoutSegment, | ||
} from 'next/navigation' | ||
|
||
export default function Page() { | ||
const selectedLayoutSegment = useSelectedLayoutSegments() | ||
const selectedLayoutSegments = useSelectedLayoutSegments() | ||
const selectedLayoutSegment = useSelectedLayoutSegment() | ||
|
||
return ( | ||
<p id="page-layout-segments">{JSON.stringify(selectedLayoutSegment)}</p> | ||
<> | ||
<p id="page-layout-segments">{JSON.stringify(selectedLayoutSegments)}</p> | ||
<p id="page-layout-segment">{JSON.stringify(selectedLayoutSegment)}</p> | ||
</> | ||
) | ||
} |
11 changes: 8 additions & 3 deletions
11
test/e2e/app-dir/app/app/hooks/use-selected-layout-segment/first/layout.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
11 changes: 8 additions & 3 deletions
11
test/e2e/app-dir/app/app/hooks/use-selected-layout-segment/layout.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
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