This repository was archived by the owner on Oct 26, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 632
syncHistoryWithStore does not respect redux stateΒ #534
Copy link
Copy link
Open
Description
Hi,
I am trying to restore the displayed page on app startup but it's always /, redux store is preloaded from local storage. HoweversyncHistoryWithStore erases the state.
I use redux-localstorage to persist redux to local storage which seems to be merging state from local storage into initialState therefore restoring the state without telling anyone which shouldn't be any different for the app when the concept of single source of truth is applied.
I am sure this issue can be reproduced with initialState with hardcoded route.
import { routerMiddleware, routerReducer as routing } from 'react-router-redux';
import persistState from 'redux-localstorage';
import thunk from 'redux-thunk';
import routes from './routes';
const router = routerMiddleware(hashHistory);
const reducers = {
routing
};
const middlewares = [ thunk, router ];
function configureStore(initialState) {
const enhancer = compose(applyMiddleware(...middlewares), persistState());
const rootReducer = combineReducers(reducers);
return createStore(rootReducer, initialState, enhancer);
}
const initialState = {};
const store = configureStore(initialState);
const routerHistory = syncHistoryWithStore(hashHistory, store);
ReactDOM.render(
<Provider store={ store }>
<Router history={ routerHistory } routes={ routes } />
</Provider>,
rootElement
);I tried adjustUrlOnReplay without luck:
const routerHistory = syncHistoryWithStore(hashHistory, store, { adjustUrlOnReplay: true });Thanks
ylg, raduflp, xlucid, AlessandroAnnini, chemoish and 5 more
Metadata
Metadata
Assignees
Labels
No labels