Skip to content

Commit

Permalink
Merge branch 'main' into release-next
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 committed Nov 14, 2023
2 parents 4f92beb + 4475b56 commit 88159a9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
2 changes: 2 additions & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- arka1002
- arnassavickas
- aroyan
- ashusnapx
- avipatel97
- awreese
- aymanemadidi
Expand Down Expand Up @@ -127,6 +128,7 @@
- kno-raziel
- koojaa
- KostiantynPopovych
- KubasuIvanSakwa
- KutnerUri
- kylegirard
- landisdesign
Expand Down
36 changes: 33 additions & 3 deletions docs/hooks/use-location.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ title: useLocation
```tsx
declare function useLocation(): Location;

interface Location extends Path {
state: any;
key: Key;
interface Location<State = any> extends Path {
state: State;
key: string;
}

interface Path {
pathname: string;
search: string;
hash: string;
}
```

Expand All @@ -38,4 +44,28 @@ function App() {
}
```

## Properties

### `location.hash`

The hash of the current URL.

### `location.key`

The unique key of this location.

### `location.pathname`

The path of the current URL.

### `location.search`

The query string of the current URL.

### `location.state`

The state value of the location created by [`<Link state>`][link-state] or [`navigate`][navigate].

[link-state]: ../components/link#state
[location]: ../utils/location
[navigate]: ./use-navigate
7 changes: 6 additions & 1 deletion docs/hooks/use-navigate.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ Specifying `replace: true` will cause the navigation to replace the current entr

## `options.state`

You may include an optional state value in to store in [history state][history-state]
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:

```tsx
navigate("/new-route", { state: { key: "value" } });
```

## `options.preventScrollReset`

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

0 comments on commit 88159a9

Please sign in to comment.