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.
CodePudding user response:
on React router v6 it should be
<BrowserRouter>
<Routes>
<Route path="/" component={<Welcome/>} exact={true} />
</Routes>
</BrowserRouter>