Search code examples
reactjsreact-routermaterial-uinavigation-drawersingle-page-application

How to use React Router with Material UI Drawer to change content on click?


I've tried using Component={Link} to={path} but that just changes the URL. The content is displayed inside main and I've used Routes inside there like so:

<main>
  <Switch>
    <Route path={..} component={..}>
    .
    .
    .
  </Switch>
</main

But this doesn't work, the content doesn't change

Link to material UI example: https://codesandbox.io/s/v66pl


Solution

  • Added to your sample as you requested: BrowserRouter, Link.

    https://codesandbox.io/s/material-demo-605w9