title: this.props.history is undefined react-router-dom
body: <p>My App.js </p>
  
  <pre><code>import React, { Component } from 'react';
  import './App.css';
  import Continue from './components/Continue';
  import Login from './components/Login';
  import Table from './components/Table';
  import Profile from './components/Profile';
  import { BrowserRouter,Switch, Route,Redirect } from 'react-router-dom'
  
  
  function loggedIn() {
     return !!localStorage.getItem('token');
  }
  class App extends Component {
     render() {
  return (
    &lt;div className="App"&gt;
      &lt;BrowserRouter  &gt;
        &lt;Switch&gt;
            &lt;Route exact path = "/" component ={Login}/&gt;
            &lt;Route
              exact
              path = "/continue"
              component = {() =&gt;
                loggedIn() ? &lt;Continue /&gt; : &lt;Redirect to="/" /&gt;}
            /&gt;
            &lt;Route
              exact
              path = "/home"
              component={() =&gt;
                loggedIn() ? &lt;Table /&gt; : &lt;Redirect to="/" /&gt;}
            /&gt;
            &lt;Route
              exact
              path = "/profile"
              component={() =&gt;
                loggedIn() ? &lt;Profile /&gt; : &lt;Redirect to="/" /&gt;}
            /&gt;        &lt;/Switch&gt;
    &lt;/BrowserRouter&gt;
    &lt;/div&gt;
    );
   }
   }
  
    export default App;
  </code></pre>
  
  <p>Then from the login form I push to the route <strong>/continue</strong></p>
  
  <pre><code>  this.props.history.push('/continue');
  </code></pre>
  
  <p>This happens successfully.</p>
  
  <p>But from <strong>Continue</strong> when I tried to push to <strong>/home</strong> same way,</p>
  
  <pre><code> this.props.history.push('/home');
  </code></pre>
  
  <p>It throws an error </p>
  
  <blockquote>
    <p>TypeError: this.props.history is undefined</p>
  </blockquote>
  
  <p>If I remove the <strong>loggedIn()</strong> make it as login route, then it works.</p>
  
  <p>Need some help to figure out how to send the prop history to other components.</p>