add a potential initialState to the store (for testing)

main
Yanick Champoux 2022-04-10 17:41:50 -04:00
parent 24b07c3557
commit 012db36e65
1 changed files with 22 additions and 25 deletions

View File

@ -11,14 +11,11 @@ if (dev && browser && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) {
composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
}
export default () => {
let initialState = undefined;
export default (initialState = undefined) => {
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) =>
@ -31,7 +28,7 @@ export default () => {
if (previous === duxStore.getState()) return;
previous = duxStore.getState();
set(previous);
if( browser ) localStorage.setItem('ship', JSON.stringify(previous));
if (browser) localStorage.setItem("ship", JSON.stringify(previous));
});
});