There\'s something driving me crazy in React, and I need your help. Basically, when the user clicks \"My Profile\", I want to redirect to the user\'s profile. To do that, I use
You need to integrate the react-router-redux.
Its look like the updated state is not reflecting in the container as redux do shallow comparison to check whether the component need to be update or not.
import {Router} from 'react-router-dom';
import { ConnectedRouter, routerReducer, routerMiddleware } from 'react-router-redux';
import createHistory from 'history/createBrowserHistory';
const history = createHistory()
const middleware = routerMiddleware(history)
const rootReducer = combineReducers({
router: routerReducer,
//other reducers
});
const store = createStore(rootReducer,applyMiddleware(middleware));
//routes
Also,at reducers,add this snippet.
let updatedStore = JSON.parse(JSON.stringify(state));