LocalReducer: fix empty case of localStorage rehydration

This commit is contained in:
Ted Blackman 2020-10-08 17:58:24 -04:00
parent 5377b2a862
commit cc6ce73fe4

View File

@ -8,7 +8,7 @@ type LocalState = Pick<StoreState, 'sidebarShown' | 'omniboxShown' | 'baseHash'
export default class LocalReducer<S extends LocalState> {
rehydrate(state: S) {
try {
const json = JSON.parse(localStorage.getItem('localReducer') || '');
const json = JSON.parse(localStorage.getItem('localReducer') || '{}');
_.forIn(json, (value, key) => {
state[key] = value;
});