How to get current route in react-router 2.0.0-rc5
<p>I have a router like below:</p>

<pre><code>&lt;Router history={hashHistory}&gt;
    &lt;Route path="/" component={App}&gt;
        &lt;IndexRoute component={Index}/&gt;
        &lt;Route path="login" component={Login}/&gt;
    &lt;/Route&gt;
&lt;/Router&gt;
</code></pre>

<p>Here's what I want to achieve :</p>

<ol>
<li>Redirect user to <code>/login</code> if not logged in</li>
<li>If user tried to access <code>/login</code> when they are already logged in, redirect them to root <code>/</code></li>
</ol>

<p>so now I'm trying to check user's state in <code>App</code>'s <code>componentDidMount</code>, then do something like:</p>

<pre><code>if (!user.isLoggedIn) {
    this.context.router.push('login')
} else if(currentRoute == 'login') {
    this.context.router.push('/')
}
</code></pre>

<p>The problem here is I can't find the API to get current route.</p>

<p>I found <a href="https://github.com/rackt/react-router/issues/119">this closed issue</a> suggested using Router.ActiveState mixin and route handlers, but it looks like these two solutions are now deprecated.</p>