title: React & MUI: Navigation on Mobile View
body: <p>I found an example of creating navigation with Drawer on <a href="https://youtu.be/zg0kjVl5b6Y" rel="nofollow noreferrer">Youtube</a> and have created a sandbox of the code here: <a href="https://codesandbox.io/s/musing-hofstadter-rj4vn?file=/src/App.js" rel="nofollow noreferrer">https://codesandbox.io/s/musing-hofstadter-rj4vn?file=/src/App.js</a></p>
  <p>I need to maintain the two pane design for large(r) screens while for the mobile view, I need to display only one pane at a time:</p>
  <ul>
  <li>when the app is first loaded - show the menu</li>
  <li>when a link is clicked - show the content</li>
  <li>when the back button on the content page is clicked - show the menu</li>
  </ul>
  <p>Web view:
  <a href="https://i.stack.imgur.com/vYC7W.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vYC7W.png" alt="enter image description here" /></a></p>
  <p>Mobile view:</p>
  <ul>
  <li>show the menu by default:</li>
  </ul>
  <p><a href="https://i.stack.imgur.com/qScwB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qScwB.png" alt="enter image description here" /></a></p>
  <ul>
  <li>when a link is clicked, show content. User can click the <code>Back</code> button to return to the menu
  <a href="https://i.stack.imgur.com/LL1SN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LL1SN.png" alt="enter image description here" /></a></li>
  </ul>
  <p>I note that I can set the Drawer's <code>open</code> value to true or false. But when I do this, there's still white space on the left side of the screen where the Drawer's supposed to be.</p>
  <p>I found a <a href="https://stackoverflow.com/questions/52396360/how-to-hide-material-ui-mini-variant-drawer-on-mobile-view">reference</a> to hide the Drawer on mobile screen, but this doesn't help me because I do need to show the Drawer when the app is first loaded, and then when a user clicks the back button on the content page.</p>
  <p>How can I accomplish this? Any help is very much appreciated. Thank you.</p>
  <p>Code:</p>
  <pre><code>import React from &quot;react&quot;;
  import { makeStyles } from &quot;@material-ui/core/styles&quot;;
  
  import { BrowserRouter as Router, Switch, Route, Link } from &quot;react-router-dom&quot;;
  
  import {
    Button,
    Drawer,
    List,
    ListItem,
    ListItemIcon,
    ListItemText,
    Container,
    Typography
  } from &quot;@material-ui/core&quot;;
  
  import HomeIcon from &quot;@material-ui/icons/Home&quot;;
  import InfoIcon from &quot;@material-ui/icons/Info&quot;;
  
  const useStyles = makeStyles((theme) =&gt; ({
    button: {
      margin: theme.spacing(1)
    },
    drawerPaper: { width: &quot;inherit&quot; },
    link: {
      textDecoration: &quot;none&quot;,
      color: theme.palette.text.primary
    }
  }));
  
  function App() {
    const classes = useStyles();
    return (
      &lt;Router&gt;
        &lt;div style={{ display: &quot;flex&quot; }}&gt;
          &lt;Drawer
            style={{ width: &quot;220px&quot; }}
            variant=&quot;persistent&quot;
            anchor=&quot;left&quot;
            open={true}
            classes={{ paper: classes.drawerPaper }}
          &gt;
            &lt;List&gt;
              &lt;Link to=&quot;/&quot; className={classes.link}&gt;
                &lt;ListItem button&gt;
                  &lt;ListItemIcon&gt;
                    &lt;HomeIcon /&gt;
                  &lt;/ListItemIcon&gt;
                  &lt;ListItemText primary={&quot;Home&quot;} /&gt;
                &lt;/ListItem&gt;
              &lt;/Link&gt;
              &lt;Link to=&quot;/about&quot; className={classes.link}&gt;
                &lt;ListItem button&gt;
                  &lt;ListItemIcon&gt;
                    &lt;InfoIcon /&gt;
                  &lt;/ListItemIcon&gt;
                  &lt;ListItemText primary={&quot;About&quot;} /&gt;
                &lt;/ListItem&gt;
              &lt;/Link&gt;
            &lt;/List&gt;
          &lt;/Drawer&gt;
          &lt;Switch&gt;
            &lt;Route exact path=&quot;/&quot;&gt;
              &lt;Container&gt;
                &lt;Button
                  variant=&quot;contained&quot;
                  color=&quot;secondary&quot;
                  className={classes.button}
                  component={Link}
                  to=&quot;/&quot;
                &gt;
                  Back
                &lt;/Button&gt;
                &lt;Typography variant=&quot;h3&quot; gutterBottom&gt;
                  Home
                &lt;/Typography&gt;
                &lt;Typography variant=&quot;body1&quot; gutterBottom&gt;
                  Lorem Ipsum is simply dummy text of the printing and typesetting
                  industry. Lorem Ipsum has been the industry's standard dummy
                  text ever since the 1500s, when an unknown printer took a galley
                  of type and scrambled it to make a type specimen book. It has
                  survived not only five centuries, but also the leap into
                  electronic typesetting, remaining essentially unchanged. It was
                  popularised in the 1960s with the release of Letraset sheets
                  containing Lorem Ipsum passages, and more recently with desktop
                  publishing software like Aldus PageMaker including versions of
                  Lorem Ipsum.
                &lt;/Typography&gt;
              &lt;/Container&gt;
            &lt;/Route&gt;
            &lt;Route exact path=&quot;/about&quot;&gt;
              &lt;Container&gt;
                &lt;Button
                  variant=&quot;contained&quot;
                  color=&quot;secondary&quot;
                  className={classes.button}
                  component={Link}
                  to=&quot;/&quot;
                &gt;
                  Back
                &lt;/Button&gt;
                &lt;Typography variant=&quot;h3&quot; gutterBottom&gt;
                  About
                &lt;/Typography&gt;
                &lt;Typography variant=&quot;body1&quot; gutterBottom&gt;
                  Contrary to popular belief, Lorem Ipsum is not simply random
                  text. It has roots in a piece of classical Latin literature from
                  45 BC, making it over 2000 years old. Richard McClintock, a
                  Latin professor at Hampden-Sydney College in Virginia, looked up
                  one of the more obscure Latin words, consectetur, from a Lorem
                  Ipsum passage, and going through the cites of the word in
                  classical literature, discovered the undoubtable source. Lorem
                  Ipsum comes from sections 1.10.32 and 1.10.33 of &quot;de Finibus
                  Bonorum et Malorum&quot; (The Extremes of Good and Evil) by Cicero,
                  written in 45 BC. This book is a treatise on the theory of
                  ethics, very popular during the Renaissance. The first line of
                  Lorem Ipsum, &quot;Lorem ipsum dolor sit amet..&quot;, comes from a line
                  in section 1.10.32.
                &lt;/Typography&gt;
              &lt;/Container&gt;
            &lt;/Route&gt;
          &lt;/Switch&gt;
        &lt;/div&gt;
      &lt;/Router&gt;
    );
  }
  
  export default App;
  </code></pre>