Connected-react-router: How to inject RouterState other than "router" key

Created on 27 Jul 2018  路  3Comments  路  Source: supasate/connected-react-router

I'm wondering how can I inject router's redux state other than router key when I use connectRouter().

In case of _react-router-redux_, this can be done by adding combining reducer manually.

import { routerReducer } from "react-router-redux";
import { combineReducers } from "redux";
import fooReducer from "./foo"

export default combineReducers({
    foo: fooReducer,
    someRouterStateKeyOtherThanRouter: routerReducer,
});

Most helpful comment

v5.0.0 supports this. (Beware of the breaking change. Please see the release note https://github.com/supasate/connected-react-router/releases/tag/v5.0.0)

All 3 comments

As far as I can see it is not possible because the "router" key is hard-coded and is used to find the data at the root of the store, see this line of code.
So the store shape should always look like this:

{
  foo: '',
  router: {
    location: {
      pathname: '/',
      search: '',
      hash: ''
    },
    action: 'POP'
  }
}

That would be a nice to have feature.

@supasate it would be great to have an export with the router state key.

v5.0.0 supports this. (Beware of the breaking change. Please see the release note https://github.com/supasate/connected-react-router/releases/tag/v5.0.0)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Guymestef picture Guymestef  路  5Comments

jhwheeler picture jhwheeler  路  3Comments

BerndWessels picture BerndWessels  路  3Comments

jjdp picture jjdp  路  4Comments

mjhoffm2 picture mjhoffm2  路  4Comments