react-redux-starter-kit
react-redux-starter-kit copied to clipboard
[Question] How to deal with the reducers when I refresh the SPA web pages?
hello , When I use this kit to create the SAP application, I find that if i refresh the web page , the reducers which i create before this route will disappear , so I have to create those reducers one more again in this route to prevent refreshing . Our data api are somthing different , there is not each route has independent data source. So, I want to know there any other way to deal with the reducers when refresh, or I am not get the important point in this kit. Thank you.
@minhuaF If your app shares data across routes you will need to import the "common" reducer into reducers.js
.
Example below:
import usersReducer from './usersReducer';
export const makeRootReducer = (asyncReducers) => {
return combineReducers({
location: locationReducer,
users: usersReducer,
...asyncReducers
})
}
Above is perfectly valid solutions, besides that reloading the web page (i.e. via refresh or whatever) will reset the redux store, so you will need to re-hydrate it either from some server stored state or local storage.