Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
describe how to use Redirect's options prop (#998)
Browse files Browse the repository at this point in the history
* describe how to use Redirects options prop

* Update docs/router.md

Co-authored-by: Tobbe Lundberg <[email protected]>

Co-authored-by: Tobbe Lundberg <[email protected]>
  • Loading branch information
odjhey and Tobbe authored Mar 18, 2022
1 parent f9b8d9f commit 16deca2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/router.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,8 @@ const SomePage = () => {
}
```

In addition to the `to` prop, `<Redirect />` also takes an `options` prop. This is the same as [`navigate()`](https://redwoodjs.com/docs/router#navigate)'s second argument: `navigate(_, { replace: true })`. We can use it to *replace* the top item of the browser history stack (instead of pushing a new one). This is how you use it to have this effect: `<Redirect to={routes.home()} options={{ replace: true }}/>`.

## Code-splitting

By default, the router will code-split on every Page, creating a separate lazy-loaded webpack bundle for each. When navigating from page to page, the router will wait until the new Page module is loaded before re-rendering, thus preventing the "white-flash" effect.
Expand Down

0 comments on commit 16deca2

Please sign in to comment.