add a potential initialState to the store (for testing)
This commit is contained in:
parent
24b07c3557
commit
012db36e65
@ -11,14 +11,11 @@ if (dev && browser && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) {
|
|||||||
composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
|
composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default () => {
|
export default (initialState = undefined) => {
|
||||||
|
|
||||||
let initialState = undefined;
|
|
||||||
|
|
||||||
if (browser) {
|
if (browser) {
|
||||||
const i =localStorage.getItem('ship');
|
const i = localStorage.getItem("ship");
|
||||||
|
|
||||||
if(i) initialState = JSON.parse(localStorage.getItem('ship'));
|
if (i) initialState = JSON.parse(localStorage.getItem("ship"));
|
||||||
}
|
}
|
||||||
|
|
||||||
const duxStore = shipDux.createStore(initialState, (mw) =>
|
const duxStore = shipDux.createStore(initialState, (mw) =>
|
||||||
@ -31,7 +28,7 @@ export default () => {
|
|||||||
if (previous === duxStore.getState()) return;
|
if (previous === duxStore.getState()) return;
|
||||||
previous = duxStore.getState();
|
previous = duxStore.getState();
|
||||||
set(previous);
|
set(previous);
|
||||||
if( browser ) localStorage.setItem('ship', JSON.stringify(previous));
|
if (browser) localStorage.setItem("ship", JSON.stringify(previous));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user