Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Route component in BrowserRoute doesn't work. When Route is removed it works

I am following a tutorial. The guy uses a code like this. I can’t figure it out why it doesn’t work on my machine. I installed all the required packages. I am wondering whether the syntax hasn’t changed (the tutorial is 2 years old).

import { BrowserRouter, Route } from 'react-router-dom';
import Welcome from './components/Welcome';

function App() {
  return (
    <BrowserRouter>
      <Route path="/" component={Welcome} exact={true} />
    </BrowserRouter>
  );
}

export default App;

When I tried it without the component but with , it worked.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

on React router v6 it should be

    <BrowserRouter>
      <Routes>
        <Route path="/" component={<Welcome/>} exact={true} />
      </Routes>
    </BrowserRouter>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading