Skip to content

Commit 0188377

Browse files
committed
Fixed: correctly handle negative scenario where localStorage.state does not exist in persistedState loader
1 parent 18ac5c6 commit 0188377

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/store/middleware/localStorage.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ export default store => next => action => {
2222
}
2323

2424
function _load() {
25-
let state = false;
25+
let state;
2626

2727
if (window.localStorage) {
28-
state = localStorage.getItem('state', 'false');
28+
state = localStorage.getItem('state', '');
2929

3030
try {
3131
state = JSON.parse(state);
@@ -41,7 +41,7 @@ export function loadPersistedState(...keys) {
4141
let state = _load();
4242

4343
for (let key of keys) {
44-
if (state !== undefined) state = state[key];
44+
if (state) state = state[key];
4545
else return;
4646
}
4747

0 commit comments

Comments
 (0)