redux-8.x-1.0-alpha1/js/src/lib/localStorage.js
js/src/lib/localStorage.js
const loadState = () => {
try {
const serializedState = localStorage.getItem('state');
if (serializedState === null) {
return undefined;
}
return JSON.parse(serializedState);
} catch (err) {
return undefined;
}
};
const saveState = (state) => {
try {
const serializedState = JSON.stringify(state);
localStorage.setItem('state', serializedState);
} catch (err) {
// Ignore write errors for now.
}
};
export { loadState, saveState };
