Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
e06983bf
Unverified
Commit
e06983bf
authored
Jul 14, 2022
by
Tim Neutkens
Committed by
GitHub
Jul 14, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure selected segment is the value of dynamic routes (#38644)
parent
b1bb3d94
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
hooks-client.ts
packages/next/client/components/hooks-client.ts
+7
-5
No files found.
packages/next/client/components/hooks-client.ts
View file @
e06983bf
...
@@ -16,13 +16,13 @@ export function useSearchParams() {
...
@@ -16,13 +16,13 @@ export function useSearchParams() {
return
useContext
(
QueryContext
)
return
useContext
(
QueryContext
)
}
}
export
function
useSearchParam
(
key
:
string
)
{
export
function
useSearchParam
(
key
:
string
)
:
string
|
string
[]
{
const
params
=
useContext
(
QueryContext
)
const
params
=
useContext
(
QueryContext
)
return
params
[
key
]
return
params
[
key
]
}
}
// TODO-APP: Move the other router context over to this one
// TODO-APP: Move the other router context over to this one
export
function
useRouter
()
{
export
function
useRouter
()
:
import
(
'../../shared/lib/app-router-context'
).
AppRouterInstance
{
return
useContext
(
AppRouterContext
)
return
useContext
(
AppRouterContext
)
}
}
...
@@ -31,7 +31,7 @@ export function useRouter() {
...
@@ -31,7 +31,7 @@ export function useRouter() {
// return useContext(ParamsContext)
// return useContext(ParamsContext)
// }
// }
export
function
usePathname
()
{
export
function
usePathname
()
:
string
{
return
useContext
(
PathnameContext
)
return
useContext
(
PathnameContext
)
}
}
...
@@ -42,8 +42,10 @@ export function usePathname() {
...
@@ -42,8 +42,10 @@ export function usePathname() {
export
function
useSelectedLayoutSegment
(
export
function
useSelectedLayoutSegment
(
parallelRouteKey
:
string
=
'children'
parallelRouteKey
:
string
=
'children'
)
{
)
:
string
{
const
{
tree
}
=
useContext
(
AppTreeContext
)
const
{
tree
}
=
useContext
(
AppTreeContext
)
return
tree
[
1
][
parallelRouteKey
][
0
]
const
segment
=
tree
[
1
][
parallelRouteKey
][
0
]
return
Array
.
isArray
(
segment
)
?
segment
[
1
]
:
segment
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment