title: Retrieve parameters from react-router in Redux reducer
body: <p><strong>I am trying to change a URL parameter when an action is dispatched. It links to the next "case" in an experiment and is presented as an integer in the URL.</strong></p>
  
  <p>How I imagine this:<br>
  Initial URL <code>/experiment/2</code><br>
  Dispatched Action <code>{ type: 'NEXT_CASE' }</code><br>
  New URL <code>/experiment/3</code></p>
  
  <p><strong>Research</strong><br>
  Based on <a href="https://stackoverflow.com/a/38084701/2525299">this answer</a> (although about <code>redux-router</code>) I got the idea that I could retrieve the current path / URL in a reducer by accessing <code>store.getState().routing</code>.</p>
  
  <p>But I want the parameters, as defined and parsed in my routes. (I obviously could parse them manually from the path but that doesn't seem scalable and not future-proof if the path structure changes.)</p>
  
  <p><strong>Current solution</strong><br>
  My best attempt so far, based on <a href="https://github.com/reactjs/react-router/blob/master/docs/API.md#match-routes-location-history-options--cb" rel="nofollow noreferrer">match</a> (which they say is not intended for client-side usage):</p>
  
  <pre><code>export default store =&gt; next =&gt; (action:Action&lt;any&gt;) =&gt; {
    if (action.type == Types.NEXT_CASE) {
      match(
        { routes: Routes, location: store.getState().routing.locationBeforeTransitions.pathname },
        (error, redirectLocation, renderProps: any) =&gt; browserHistory.push(RouteBuilder.experiment(parseInt(renderProps.params.caseIndex) + 1))
      );
    }
  
    return next(action);
  }
  </code></pre>
  
  <p>Where <code>Routes</code> and <code>RouteBuilder</code> are defined as follows:</p>
  
  <pre><code>export const RouteBuilder = {
    experiment: (caseIndex: number) =&gt; `/experiment/${ caseIndex }`
  };
  
  export const Routes = (
    &lt;Route path="/" component={ Root }&gt;
      &lt;IndexRoute component={ Welcome } /&gt;
      &lt;Route path="experiment/:caseIndex" component={ Experiment } /&gt;
    &lt;/Route&gt;
  );
  </code></pre>
  
  <p><strong>Question</strong><br>
  Is there any straightforward way to retrieve the current route's (parsed and named) parameters in a reducer?</p>