aswi2022code-of-duty-gitlab/frontend/src/utils/statePersistence.ts @ 4a2ac9a8
1 |
// TODO this could be replaced with redux library
|
---|---|
2 |
const persist = (name: string, value: any) => { |
3 |
localStorage.setItem(name, JSON.stringify(value)) |
4 |
return value |
5 |
}
|
6 |
|
7 |
const load = (name: string) => { |
8 |
const item = localStorage.getItem(name) |
9 |
return item ? JSON.parse(item) : undefined |
10 |
}
|
11 |
|
12 |
export { persist, load } |