Can I create alias routes using react router?
I am using react-router-dom v4.3.1 and as of this version multiple paths can be provided as an array to the path prop on the Route component like:
<Route path={["oldListUrl", "newListUrl"]} component={ItemList}/>
I believe this is much better than redirects. Hope this helps!
Assuming that you're using React-Router v4
you can use Redirect
component like this:
<Route path="newListUrl" component={ItemList}/><Route path='/oldListUrl' render={() => ( <Redirect to="newUrl" />)}/>
If you're using React-Router v3
:
<Route path="newListUrl" component={ItemList}/><Redirect from='oldListUrl'to="newListUrl" />