How do you get the current location when using "response-router-redux"?
This condition is routing:
{
routing: {
locationBeforeTransition: {
pathname: "/foo",
search: "",
hash: "",
state: null,
action: "PUSH",
key: "e8jfk"
},
query: null,
$searchBase: {
search: "",
searchBase: ""
}
}
}
I can access the current location as state.routing.locationBeforeTransition.pathname, but the name "locationBeforeTransition" looks like it will be the previous page location, not the current one. It also seems strange that this is the only property in my routing state. I suspect I'm doing something wrong.
Here is a simplified reducer that only has routing:
reducer.js
import { combineReducers, createStore, applyMiddleware, compose } from 'redux';
import { routerReducer, routerMiddleware } from 'react-router-redux';
import { browserHistory } from 'react-router';
import thunkMiddleware from 'redux-thunk';
const reducer = combineReducers({
routing: routerReducer,
});
export const store = createStore(reducer, {}, compose(
applyMiddleware(
routerMiddleware(browserHistory),
thunkMiddleware
),
window.devToolsExtension ? window.devToolsExtension() : f => f
)
);
Don p source
share