react-router6-redirect
v1.0.1
Published
Redirect component for react-router v6
Downloads
5,020
Maintainers
Readme
react-router6-redirect
Redirect component for react-router v6.
Renders a <Navigate replace/>
component and handles any dynamic parts.
Why is this needed?
react-router v6 <Navigate>
component does not handle dynamic parts of the to
prop.
Install
npm i react-router6-redirect
Setup
import {Route} from 'react-router-dom'
import {Redirect} from 'react-router6-redirect';
Usage
Important: each param name present in the Redirect
's to
prop must exist in the Route
's path
prop.
<Route path="original/path/:id" element={<Redirect to="different/:id"/>}/>
Supported props
export interface RedirectProps {
to: string;
state?: any;
relative?: RelativeRoutingType;
}