title: Redirect for default case in React using Switch and BrowserRouter
body: <p>This is my current App.js file in react. What I am trying to achieve is everytime a link of the first switch is accessed, i do not want the navbar to be shown, but otherwise, the navbar has to be visible. I do not have a default case, so I am stuck. If this may help anyone, if the user is already logged in, accessing login/logout directly redirects you to home and if he is not logged in, accessing any other page redirects you to the login page. It would be very helpful if you have a workaround. </p>
  
  <pre><code>&lt;BrowserRouter&gt;
    &lt;Switch&gt;
      &lt;Route path='/user/register' component={Register} /&gt;
      &lt;Route path='/user/login' component={Login} /&gt;
      &lt;Route path='/user/logout' component={Logout} /&gt;
      &lt;Navbar /&gt;
    &lt;/Switch&gt;
    &lt;Switch&gt;  
      &lt;Route path='/note/new' component={NewNote} /&gt;
      &lt;Route path='/list/new' component={NewList} /&gt;
      &lt;Route path='/note/:noteid' component={NoteDetail} /&gt;
      &lt;Route path='/list/:listid' component={ListDetail} /&gt;
      &lt;Route path='/home' component={Home} /&gt;
      &lt;Route path='/archive' component={Archive} /&gt;
      &lt;Route path='/note' component={Note} /&gt;
      &lt;Route path='/list' component={List} /&gt;
      &lt;Route path='/trash' component={Trash} /&gt;
    &lt;/Switch&gt;
  &lt;/BrowserRouter&gt;
  </code></pre>
  
  <p>Thanks</p>