I can't use Switch from react auto import, where I'm able to auto import Router from react.
import { BrowserRouter as Router } from 'react-router-dom';
function App() {
return (
<div>
<Router>
<Switch>
</Switch>
</Router>
</div>
);
}
The problem you have is because you did not import the Switch component from react-router.
Per the documentation, you need to do the following:
import { Route, Switch } from "react-router";
let routes = (
<Switch>
<Route exact path="/">
<Home />
</Route>
<Route path="/about">
<About />
</Route>
<Route path="/:user">
<User />
</Route>
<Route>
<NoMatch />
</Route>
</Switch>
);
So in your case:
import { BrowserRouter as Router } from 'react-router-dom';
import { Switch } from "react-router";
function App() {
return (
<div>
<Router>
<Switch>
</Switch>
</Router>
</div>
);
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments