Why is BrowserRouter and Route from 'react-router-dom' not working properly?
Since react-router-dom
v6, some props changed for components that it exposes such as Route
, and Switch
is replaced by Routes
:
Here is your code modified to match with new changes:
function App() {
return (
<BrowserRouter>
<Routes>
<Route path="/" element={<Home />}></Route>
</Routes>
</BrowserRouter>
);
}
export default App;
Also, no need for <>
(aka React.Fragment
since BrowserRouter
is the only item present in jsx.