Tarlen Tarlen - 1 year ago 120
React JSX Question

Get route params inside actioncreator/selector?

Using redux router, In my components I have access to the

object with information about by URL.

However, inside my actioncreators, I get the state through
, and thus the params props has not been injected.

Is there a way around this?

Answer Source

to get access params in action creators, you should pass it:

in component


in action creator

const someAction = (params)=>{
    let {data} = params;

to get access params in selector, you should pass it:

in component

const mapStateToProps=(state, ownProps)=({

in selector

const someSelector=(state, params)={
   ..some computing
   return result

to get access from getState() to router's params, pathname and query:

you need to install redux-router

if you allready using it , then check


import { ReduxRouter } from 'redux-router';

<Provider store={store}>
            <Route path="/" component={App}>


import { routerStateReducer } from 'redux-router';
const reducer = combineReducers({
router: routerStateReducer,

3.store enchancer

import { reduxReactRouter} from 'redux-router';
import { createHistory } from 'history';
import { compose, createStore, applyMiddleware } from 'redux';
const store = compose(
  applyMiddleware(m1, m2, ...),
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download