Redirect component for react-router v6.
Renders a <Navigate replace/>
component and handles any dynamic parts.
react-router v6 <Navigate>
component does not handle dynamic parts of the to
prop.
npm i react-router6-redirect
import {Route} from 'react-router-dom'
import {Redirect} from 'react-router6-redirect';
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"/>}/>
export interface RedirectProps {
to: string;
state?: any;
relative?: RelativeRoutingType;
}