title: React ocation.pathname typerror: Cannot call location.pathname in one file, but can in other file
body: <p>In one of my Components, I can easily call a "this.props.location.pathname". But when I try this in another component I get </p>
  
  <blockquote>
    <p>TypeError: Cannot read property 'pathname' of undefined</p>
  </blockquote>
  
  <p>And I can't seem to find out what is different..</p>
  
  <h2>WORKS:</h2>
  
  <pre><code>import React, { Component } from 'react';
  import { Redirect } from 'react-router-dom';
  
  export default class RedirectUser extends Component  {
      render () {
          return (
              &lt;span className='redirecting'&gt;
                  {this.props.location.pathname === '/' || this.props.location.pathname === '/mgmt' || this.props.location.pathname === '/mgmt/' ?
                      &lt;Redirect to='/mgmt/entrepreneurs' /&gt;
                  : this.props.location.pathname === '/user' || this.props.location.pathname === '/user/' ? 
                      &lt;Redirect to='/user/settings' /&gt;
                  : this.props.location.pathname === '/dev' || this.props.location.pathname === '/dev/' ? 
                      &lt;Redirect to='/dev/story' /&gt;
                  : null
                  }
              &lt;/span&gt;
          );
      }
  };
  </code></pre>
  
  <h2>DOESN'T WORK</h2>
  
  <pre><code>import React, { Component } from 'react';
  import { NavLink, Link } from 'react-router-dom';
  import Icon from '../library/icons/Icon';
  import '../App.css';
  import { UserConsumer } from '../App.js';
  import ProfilePicture from '../library/imgs/examples/profilepic.jpg';
  
  export default class MainNavigation extends Component  {
      constructor (props) {
          super (props)
          this.state = {
              nav: this.props.location.pathname === '/mgmt' ? 
                      'management' 
                  :this.props.location.pathname === '/social' ? 
                      'social' 
                  :this.props.location.pathname === '/work' ?
                      'work'
                  :this.props.location.pathname === '/dev' ?
                      'dev'
                  : 'management',
              navFloat: false,
              greeting: '',
              mobileMenu: false
          }
          this.closeNavTab = this.closeNavTab.bind(this);
      }
  ...
  ...
  </code></pre>