title: Redux; accessing other parts of the state when using composed reducers via combineReducers
body: <p><strong>Update</strong></p>
  
  <p>Thanks to @Dominic Tobias and @gabdallah for spotting my embarrassing mistake.</p>
  
  <p>The correct answer is of course;</p>
  
  <blockquote>
    <p>so try checking <code>action.payload</code>.</p>
  </blockquote>
  
  <p>The other comments regarding the switch statement and the action object we're referring to errors I made in my example, which I've since corrected.</p>
  
  <hr>
  
  <p>Imagine I've combined the the following two reducers;</p>
  
  <pre><code>import { combineReducers } from 'redux'
  import { routerStateReducer } from 'redux-router'
  import entries from './entries'
  
  export default combineReducers({
    router: routerStateReducer,
    entries
  })
  </code></pre>
  
  <p>I would like to mutate the entries state based on another part of the global state, in this case; the router state provided by redux-router in order for example to implement pagination.</p>
  
  <p>How could I do something like this?</p>
  
  <pre><code>// entries.js
  import { ROUTER_DID_CHANGE } from 'redux-router/lib/constants'
  const initialState = {}
  
  function entries (state = initialState, action) {
    switch (action.type) {
      case ROUTER_DID_CHANGE:
        // How can I access `state.router` here in order to do something like this;
        if (routerState.location.pathname === '/entries') {
          return {
            ...state,
            page: routerState.location.query.page || state.page,
            limit: routerState.location.query.limit || state.limit
          }
        }
        return state
    }
  }
  </code></pre>
  
  <p>Some other approaches that come to mind;</p>
  
  <ul>
  <li>connect the router state to the <code>Entries</code> route component, use the componentWillMount lifecycle method to check router state and call an action creator with the page and limit values mutating the entries state in turn. This would work; however I'm using some transition middleware to call a static <code>fetchData</code> method on the route component prior to mounting it, so the data get's fetched, then the pagination action creator would be called afterwards; not the desired behaviour.</li>
  <li>listen to router actions somewhere else (i.e a dedicated router redux module), call an action creator on the entries store, but I'm not sure how well this fits with redux-router or how I would get access to the router part of the global store.</li>
  <li>don't do this at all; simply query the router state in the static fetchData method</li>
  </ul>
  
  <p>Other useful info;</p>
  
  <p>The implementation in question is Universal App heavily inspired by react-redux-universal-hot-example</p>
  
  <p>Relevant deps</p>
  
  <ul>
  <li>react 0.14.2</li>
  <li>redux 3.0.3</li>
  <li>react-router 1.0.0-rc3</li>
  <li>redux-router 1.0.0-beta3</li>
  </ul>
  
  <p>How can I achieve this or similar behaviour? Am I even thinking about this the right way? </p>