react-router6-redirect
v1.0.1
Published
Redirect component for react-router v6
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-redirectSetup
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;
}