I've set up my React router in App.js. Pages component do render. When I click on a link, then the Page component won't render, but the URL in the browser changes to "page/{id}". Why is this?
Pages component:
function Pages(props) { const managedPages = JSON.parse(localStorage.getItem("managedPages")); console.log(managedPages);
return (
<div>
<List>
{managedPages.map(page => (
<ListItem key={page.id}>
<Link
to={`/page/${page.id}`}
style={{ textDecoration: "none", color: "black" }}
>
<ListItemText primary="Teszt Színház" />
</Link>
</ListItem>
))}
</List>
<Route path="/page" component={Page} />
</div> ); }
App.js jsx:
return (
<MuiPickersUtilsProvider utils={MomentUtils}>
<BrowserRouter>
<div className="App">
<BarAndMenu
userLoginAndDataDownloadCompletedOut={
this.userLoginAndDataDownloadCompletedOut
}
/>
</div>
<Switch>
<Route path="/" exact component={OngoingEventList} />
<Route path="/selectSeat" component={SelectSeat} />
<Route path="/releasePurpose/:id" component={ReleasePurpose} />
<Route
path="/marketingResourceConfigurationAndResult/:id"
component={MarketingResourceConfigurationAndResult}
/>
<Route path="/myTickets" exact component={MyTicketList} />
<Route path="/myTickets/:id" component={MyTicket} />
<Route path="/auditoriumList/:id" component={AuditoriumSelector} />
<Route path="/pages" component={Pages} />
</Switch>
</BrowserRouter>
</MuiPickersUtilsProvider utils={MomentUtils}>
);