qortal-ui/core/src/localStorageHelpers.js
AlphaX-Projects fa29ff4c43 Update UI
Refactor and added new functioms
2024-05-08 13:16:23 +02:00

19 lines
505 B
JavaScript

export const loadStateFromLocalStorage = (key) => {
try {
const config = localStorage.getItem(key)
if (config === null) return void 0
return JSON.parse(config)
} catch (e) {
// Could add error handling in case there's a weird one...don't want to overwrite config if it's malfunctioned
return void 0
}
}
export const saveStateToLocalStorage = (key, state) => {
try {
const stateJSON = JSON.stringify(state)
localStorage.setItem(key, stateJSON)
} catch (e) {
console.error(e, 'e')
}
}