Skip to content

Commit 43cc1aa

Browse files
authored
docs(components/link): Update for Link types and add replace/state props sections (#9971)
1 parent e0c5760 commit 43cc1aa

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/components/link.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ interface LinkProps
2121
state?: any;
2222
to: To;
2323
reloadDocument?: boolean;
24+
preventScrollReset?: boolean;
25+
relative?: "route" | "path";
2426
}
2527

2628
type To = string | Partial<Path>;
@@ -116,5 +118,26 @@ An example when you might want this behavior is a list of tabs that manipulate t
116118
117119
```
118120

121+
## `replace`
122+
123+
The `replace` property can be used if you'd like to replace the current entry in the history stack via [`history.replaceState`][history-replace-state] instead of the default usage of [`history.pushState`][history-push-state].
124+
125+
## `state`
126+
127+
The `state` property can be used to set a stateful value for the new location which is stored inside [history state][history-state]. This value can subsequently be accessed via `useLocation()`.
128+
129+
```tsx
130+
<Link to="new-path" state={{ some: "value" }} />
131+
```
132+
133+
You can access this state value while on the "new-path" route:
134+
135+
```ts
136+
let { state } = useLocation();
137+
```
138+
119139
[link-native]: ./link-native
120140
[scrollrestoration]: ./scroll-restoration
141+
[history-replace-state]: https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState
142+
[history-push-state]: https://developer.mozilla.org/en-US/docs/Web/API/History/pushState
143+
[history-state]: https://developer.mozilla.org/en-US/docs/Web/API/History/state

0 commit comments

Comments
 (0)