forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Full remaining path in selected layout segment (vercel#41562)
Make `useSelectedLayoutSegment` include the remaining segments from the current level to the leaf node. ## 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 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
Showing
11 changed files
with
132 additions
and
7 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
11 changes: 11 additions & 0 deletions
11
...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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use client' | ||
|
||
import { useSelectedLayoutSegment } from 'next/navigation' | ||
|
||
export default function Page() { | ||
const selectedLayoutSegment = useSelectedLayoutSegment() | ||
|
||
return ( | ||
<p id="page-layout-segments">{JSON.stringify(selectedLayoutSegment)}</p> | ||
) | ||
} |
3 changes: 3 additions & 0 deletions
3
.../app-dir/app/app/hooks/use-selected-layout-segment/first/[dynamic]/(group)/second/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 null | ||
} |
3 changes: 3 additions & 0 deletions
3
test/e2e/app-dir/app/app/hooks/use-selected-layout-segment/first/[dynamic]/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 null | ||
} |
14 changes: 14 additions & 0 deletions
14
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use client' | ||
|
||
import { useSelectedLayoutSegment } from 'next/navigation' | ||
|
||
export default function Layout({ children }) { | ||
const selectedLayoutSegment = useSelectedLayoutSegment() | ||
|
||
return ( | ||
<> | ||
<p id="inner-layout">{JSON.stringify(selectedLayoutSegment)}</p> | ||
{children} | ||
</> | ||
) | ||
} |
3 changes: 3 additions & 0 deletions
3
test/e2e/app-dir/app/app/hooks/use-selected-layout-segment/first/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 null | ||
} |
14 changes: 14 additions & 0 deletions
14
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use client' | ||
|
||
import { useSelectedLayoutSegment } from 'next/navigation' | ||
|
||
export default function Layout({ children }) { | ||
const selectedLayoutSegment = useSelectedLayoutSegment() | ||
|
||
return ( | ||
<> | ||
<p id="outer-layout">{JSON.stringify(selectedLayoutSegment)}</p> | ||
{children} | ||
</> | ||
) | ||
} |
1 change: 0 additions & 1 deletion
1
test/e2e/app-dir/app/app/hooks/use-selected-layout-segment/server/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
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