Reputation: 1099
I'm trying to build a simple component that will make one API call and after 2 seconds will redirect to another page. For that, I tried to use the Redirect component from react-router-dom, but the import fails
import { Redirect } from "react-router-dom"
I'm getting the error: "react-router-dom has no exported member 'Redirect'."
version "react-router-dom": "^6.0.0-beta.0",
Upvotes: 2
Views: 1274
Reputation: 17474
It looks like the <Redirect />
in v5 has been replaced by <Navigate />
which can also be used in the same way.
import { Navigate } from 'react-router-dom';
function App() {
return <Navigate to="/home" />;
}
Upvotes: 5