Skip to content

Commit 88159a9

Browse files
committed
Merge branch 'main' into release-next
2 parents 4f92beb + 4475b56 commit 88159a9

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

contributors.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- arka1002
2323
- arnassavickas
2424
- aroyan
25+
- ashusnapx
2526
- avipatel97
2627
- awreese
2728
- aymanemadidi
@@ -127,6 +128,7 @@
127128
- kno-raziel
128129
- koojaa
129130
- KostiantynPopovych
131+
- KubasuIvanSakwa
130132
- KutnerUri
131133
- kylegirard
132134
- landisdesign

docs/hooks/use-location.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@ title: useLocation
1010
```tsx
1111
declare function useLocation(): Location;
1212

13-
interface Location extends Path {
14-
state: any;
15-
key: Key;
13+
interface Location<State = any> extends Path {
14+
state: State;
15+
key: string;
16+
}
17+
18+
interface Path {
19+
pathname: string;
20+
search: string;
21+
hash: string;
1622
}
1723
```
1824

@@ -38,4 +44,28 @@ function App() {
3844
}
3945
```
4046

47+
## Properties
48+
49+
### `location.hash`
50+
51+
The hash of the current URL.
52+
53+
### `location.key`
54+
55+
The unique key of this location.
56+
57+
### `location.pathname`
58+
59+
The path of the current URL.
60+
61+
### `location.search`
62+
63+
The query string of the current URL.
64+
65+
### `location.state`
66+
67+
The state value of the location created by [`<Link state>`][link-state] or [`navigate`][navigate].
68+
69+
[link-state]: ../components/link#state
4170
[location]: ../utils/location
71+
[navigate]: ./use-navigate

docs/hooks/use-navigate.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ Specifying `replace: true` will cause the navigation to replace the current entr
6060

6161
## `options.state`
6262

63-
You may include an optional state value in to store in [history state][history-state]
63+
You may include an optional `state` value to store in [history state][history-state], which you can then access on the destination route via [`useLocation`][use-location]. For example:
64+
65+
```tsx
66+
navigate("/new-route", { state: { key: "value" } });
67+
```
6468

6569
## `options.preventScrollReset`
6670

@@ -109,6 +113,7 @@ The `unstable_viewTransition` option enables a [View Transition][view-transition
109113
[actions]: ../route/action
110114
[history-state]: https://developer.mozilla.org/en-US/docs/Web/API/History/state
111115
[scrollrestoration]: ../components/scroll-restoration
116+
[use-location]: ../hooks/use-location
112117
[use-view-transition-state]: ../hooks//use-view-transition-state
113118
[view-transitions]: https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API
114119
[picking-a-router]: ../routers/picking-a-router

0 commit comments

Comments
 (0)