Skip to content

Commit

Permalink
Redirect additional nav props.
Browse files Browse the repository at this point in the history
  • Loading branch information
molefrog committed Feb 2, 2024
1 parent a2835f1 commit d54e0a4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,18 @@ When no route in switch matches, the last empty `Route` will be used as a fallba
When mounted performs a redirect to a `path` provided. Uses `useLocation` hook internally to trigger
the navigation inside of a `useEffect` block.

`Redirect` can also accept props for [customizing how navigation will be performed](#additional-navigation-parameters), for example for setting history state when navigating. These options are specific to the currently used location hook.

```jsx
<Redirect to="/" />

// arbitrary state object
<Redirect to="/" state={{ modal: true }} />

// use `replaceState`
<Redirect to="/" replace />
```

If you need more advanced logic for navigation, for example, to trigger the redirect inside of an
event handler, consider using
[`useLocation` hook instead](#uselocation-working-with-the-history):
Expand Down

0 comments on commit d54e0a4

Please sign in to comment.