1<BrowserRouter>
2 <Switch>
3 //your routes here
4 </Switch>
5</BrowserRouter>
6
1You need to wrap the Switch with BrowserRouter or other alternatives like HashRouter, MemoryRouter. This is because BrowserRouter and alternatives are the common low-level interface for all router components and they make use of the HTML 5 history API, and you need this to navigate back and forth between your routes.
2
3Try doing this rather
4
5import { BrowserRouter, Switch, Route } from 'react-router-dom';
6And then wrap everything like this
7
8<BrowserRouter>
9 <Switch>
10 //your routes here
11 </Switch>
12</BrowserRouter>