Skip to content

Commit

Permalink
refactor: getDataFromLocalStorage에도 타입 지정
Browse files Browse the repository at this point in the history
  • Loading branch information
feb-dain committed May 22, 2023
1 parent 50e4503 commit 37ee41c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/utils/getAndSetDataInLocalStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ export const setDataInLocalStorage = <T>(key: string, data: T) => {
localStorage.setItem(key, JSON.stringify(data));
};

export const getDataFromLocalStorage = (key: string) => {
return localStorage.getItem(key);
export const getDataFromLocalStorage = (key: string): string => {
const data = localStorage.getItem(key);

if (!data) return '[]';
return data;
};

0 comments on commit 37ee41c

Please sign in to comment.