Back to React Router

Navigate

docs/api/components/Navigate.md

7.6.21.6 KB
Original Source

Navigate

<!-- ⚠️ ⚠️ IMPORTANT ⚠️ ⚠️ Thank you for helping improve our documentation! This file is auto-generated from the JSDoc comments in the source code, so please edit the JSDoc comments in the file below and this file will be re-generated once those changes are merged. https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/components.tsx -->

[MODES: framework, data, declarative]

Summary

Reference Documentation ↗

A component-based version of useNavigate to use in a React.Component class where hooks cannot be used.

It's recommended to avoid using this component in favor of useNavigate.

tsx
<Navigate to="/tasks" />

Signature

tsx
function Navigate({ to, replace, state, relative }: NavigateProps): null

Props

relative

How to interpret relative routing in the to prop. See RelativeRoutingType.

replace

Whether to replace the current entry in the History stack

state

State to pass to the new Location to store in history.state.

to

The path to navigate to. This can be a string or a Path object