aswi2022code-of-duty-gitlab/frontend/src/utils/statePersistence.ts @ c5787e2d
1 | c7d2ced1 | Václav Honzík | // 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 } |