We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d7ad87b commit 7a41257Copy full SHA for 7a41257
src/utils/storage.ts
@@ -1,14 +1,14 @@
1
const storage = window.localStorage;
2
3
-export const setItem = (key, value) => {
+export const setItem = (key: string, value: string) => {
4
try {
5
storage.setItem(key, value);
6
} catch (error) {
7
console.log(error);
8
}
9
};
10
11
-export const getItem = (key, defaultValue) => {
+export const getItem = <T>(key: string, defaultValue: T): T => {
12
13
const data = storage.getItem(key);
14
if (data) return JSON.parse(data);
0 commit comments