2
votes

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",

1

1 Answers

3
votes

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" />;
}