Skip to content

Commit 55722b9

Browse files
Update on file use-location.md (#10980)
Co-authored-by: Matt Brophy <[email protected]>
1 parent bf85c4b commit 55722b9

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

contributors.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,4 @@
242242
- yracnet
243243
- yuleicul
244244
- zheng-chuang
245+
- KubasuIvanSakwa

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

0 commit comments

Comments
 (0)