Skip to content

Commit 6ae433a

Browse files
Carlos Wutimdorr
Carlos Wu
authored andcommitted
fix #6168 (#6169)
1 parent 2189ab9 commit 6ae433a

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

packages/react-router/docs/api/Redirect.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,21 @@ The URL to redirect to. Any valid URL path that [`path-to-regexp@^1.7.0`](https:
2020
All URL parameters that are used in `to` must be covered by `from`.
2121

2222
```jsx
23-
<Redirect to="/somewhere/else"/>
23+
<Redirect to="/somewhere/else" />
2424
```
2525

2626
## to: object
2727

2828
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.
2929

3030
```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+
/>
3638
```
3739

3840
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
4244
When `true`, redirecting will push a new entry onto the history instead of replacing the current one.
4345

4446
```jsx
45-
<Redirect push to="/somewhere/else"/>
47+
<Redirect push to="/somewhere/else" />
4648
```
4749

4850
## from: string
@@ -57,9 +59,7 @@ This can only be used to match a location when rendering a `<Redirect>` inside o
5759
<Redirect from='/old-path' to='/new-path'/>
5860
<Route path='/new-path' component={Place}/>
5961
</Switch>
60-
```
6162

62-
```jsx
6363
// Redirect with matched parameters
6464
<Switch>
6565
<Redirect from='/users/:id' to='/users/profile/:id'/>

0 commit comments

Comments
 (0)