lagunovsky / redux-react-router

A Redux binding for React Router v6
MIT License
72 stars 9 forks source link

Storing reducer with custom key #18

Closed mpopov closed 1 year ago

mpopov commented 1 year ago

Since we have a constant const ROUTER_REDUCER_MAP_KEY = 'router' storing reducer with key 'navigator' like in example doesn't work: const rootReducer = combineReducers({ navigator: createRouterReducer(history) })

lagunovsky commented 1 year ago

This constant is only used in the built-in selector.

You need to use the routerSelector: <ReduxRouter history={history} routerSelector={state => state.navigator}/>

mpopov commented 1 year ago

I've tried to use action creators, didn't even use selector, copied that combineReducers line with 'navigator' and have a bunch of errors 'TypeError: state is undefined' from inside a bundle, not my code. Than renamed key to 'router' and everything works like a charm. Let me double check in more simple example a bit later :)