Skip to content

Commit

Permalink
docs: emphasize v5 and v6 navigation difference (#8414)
Browse files Browse the repository at this point in the history
  • Loading branch information
markivancho committed Nov 30, 2021
1 parent 6cbb99d commit caa7575
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
- elylucas
- hongji00
- JakubDrozd
- markivancho
12 changes: 12 additions & 0 deletions docs/upgrading/v5.md
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,18 @@ function App() {
}
```

**Note**: Be aware that the v5 `<Redirect />` uses `replace` logic by default (you may change it via `push` prop), on the other hand, the v6 `<Navigate />` uses `push` logic by default and you may change it via `replace` prop.

```js
// Change this:
<Redirect to="about" />
<Redirect to="home" push />

// to this:
<Navigate to="about" replace />
<Navigate to="home" />
```

If you're currently using `go`, `goBack` or `goForward` from `useHistory` to navigate backwards and forwards, you should also replace these with `navigate` with a numerical argument indicating where to move the pointer in the history stack. For example, here is some code using v5's `useHistory` hook:

```js
Expand Down

0 comments on commit caa7575

Please sign in to comment.