Get the current path in a react component
<p>To determine the styling of specific menu item, I am trying to get the current path in my Navigation component.</p>

<p>I tried some of the usual suspects already, but cannot get any results. Especially properties that I thought would be injected via React are not there.</p>

<p><code>this.props.location</code> returns <code>undefined</code> </p>

<p><code>this.props.context</code> returns <code>undefined</code></p>

<p>I use <code>react 15</code>, <code>redux 3.5</code>, <code>react-router 2</code>, <code>react-router-redux 4</code></p>

<pre class="lang-js prettyprint-override"><code>import React, {Component, PropTypes} from 'react';
import styles from './Navigation.css';
import NavigationItem from './NavigationItem';

class Navigation extends Component {

  constructor(props) {
    super(props);
  }

  getNavigationClasses() {
    let {navigationOpen, showNavigation} = this.props.layout;
    let navigationClasses = navigationOpen ? styles.navigation + ' ' + styles.open : styles.navigation;
    if (showNavigation) {
      navigationClasses = navigationClasses + ' ' + styles.collapsed;
    }
    return navigationClasses;
  }

  render() {
  /*
  TODO:  get pathname for active marker
  */

    let navigationClasses = this.getNavigationClasses();
    return (
      &lt;div
        className={navigationClasses}
        onClick={this.props.onToggleNavigation}
      &gt;

        {/* Timeline */}
        &lt;NavigationItem
          linkTo='/timeline'
          className={styles.navigationItem + ' ' + styles.timeline}
          displayText='Timeline'
          iconType='timeline'
        /&gt;

        {/* Contacts */}
        &lt;NavigationItem
          linkTo='/contacts'
          className={styles.navigationItem + ' ' + styles.contact + ' ' + styles.active}
          displayText='Contacts'
          iconType='contacts'
        /&gt;

      &lt;/div&gt;
    );
  }
}

Navigation.propTypes = {
  layout: PropTypes.object,
  className: PropTypes.string,
  onToggleNavigation: PropTypes.func
};

export default Navigation;
</code></pre>