So, I have observed one interesting thing when I uses the <BrowserRouter>
wrapper inside my App
structure. It does not fires location change (@@router/LOCATION_CHANGE
) action dispatch on each location change and does not update location
props in router
object inside Redux
store
, only fires on initial mount instead.
So there is how my App structure looks like:
import React from 'react';
import { Provider } from 'react-redux';
import { BrowserRouter, Switch, Route } from 'react-router-dom';
import { ConnectedRouter } from 'connected-react-router';
const AppContainer = ({ store, history }) => {
return (
<Provider store={store}>
<ConnectedRouter history={history}>
<BrowserRouter> // that is one is blocking action location dispatch
<AppLayout>
<Switch location={location}>
<Route exact path='/' component={HelloWorld} />
<Route path='/next' component={StartCoding} />
</Switch>
</AppLayout>
</BrowserRouter>
</ConnectedRouter>
</Provider>
);
};
And interesting thing is, that if I fully remove the wrapper <BrowserRouter>
from app structure the action dispatch @@router/LOCATION_CHANGE
fires normally...
Any one know what is this magic is and is it bad to remove it or not?