You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/react-router/docs/api/Redirect.md
+9-9Lines changed: 9 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -20,19 +20,21 @@ The URL to redirect to. Any valid URL path that [`path-to-regexp@^1.7.0`](https:
20
20
All URL parameters that are used in `to` must be covered by `from`.
21
21
22
22
```jsx
23
-
<Redirect to="/somewhere/else"/>
23
+
<Redirect to="/somewhere/else"/>
24
24
```
25
25
26
26
## to: object
27
27
28
28
A location to redirect to. `pathname` can be any valid URL path that [`path-to-regexp@^1.7.0`](https://github.com/pillarjs/path-to-regexp/tree/v1.7.0) understands.
29
29
30
30
```jsx
31
-
<Redirect to={{
32
-
pathname:'/login',
33
-
search:'?utm=your+face',
34
-
state: { referrer: currentLocation }
35
-
}}/>
31
+
<Redirect
32
+
to={{
33
+
pathname:"/login",
34
+
search:"?utm=your+face",
35
+
state: { referrer: currentLocation }
36
+
}}
37
+
/>
36
38
```
37
39
38
40
The `state` object can be accessed via `this.props.location.state` in the redirected-to component. This new `referrer` key (which is not a special name) would then be accessed via `this.props.location.state.referrer` in the `Login` component pointed to by the pathname `'/login'`
@@ -42,7 +44,7 @@ The `state` object can be accessed via `this.props.location.state` in the redire
42
44
When `true`, redirecting will push a new entry onto the history instead of replacing the current one.
43
45
44
46
```jsx
45
-
<Redirect push to="/somewhere/else"/>
47
+
<Redirect push to="/somewhere/else"/>
46
48
```
47
49
48
50
## from: string
@@ -57,9 +59,7 @@ This can only be used to match a location when rendering a `<Redirect>` inside o
0 commit comments