mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
WIP
This commit is contained in:
23
client/src/store/localStorage.js
Normal file
23
client/src/store/localStorage.js
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
const LOCAL_STORAGE_NAMESPACE = 'application_state';
|
||||
|
||||
export const loadState = () => {
|
||||
try {
|
||||
const serializedState = localStorage.getItem(LOCAL_STORAGE_NAMESPACE);
|
||||
if (serializedState === null) {
|
||||
return undefined;
|
||||
}
|
||||
return JSON.parse(serializedState);
|
||||
} catch(error) {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
export const saveState = (state) => {
|
||||
try {
|
||||
const serializedState = JSON.stringify(state);
|
||||
localStorage.setItem(LOCAL_STORAGE_NAMESPACE, serializedState);
|
||||
} catch (error) {
|
||||
throw new Error('Something want wrong');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user