In React Router v5, there was a <Redirect> component that you could use to redirect the user from one route to another as shown below:
import React from 'react';
import { Switch, Route, Redirect } from 'react-router-dom';
// ...
function App() {
// ...
return (
<div>
<Header />
<Switch>
<Route path="/" element={<HomePage />} />
<Route path="/project" element={<Redirect to="/project/list" />} />
<Route path="/project/list" element={<ProjectListPage />} />
</Switch>
<Footer />
</div>
);
}
export default App;
However this produces the following error with v6:
Currently the top search result, when I look for "react router redirect" is: https://v5.reactrouter.com/web/api/Redirect
Which is clearly outdated.