diff --git a/src/hooks/useLocalStorage.ts b/src/hooks/useLocalStorage.ts new file mode 100644 index 0000000..7a09838 --- /dev/null +++ b/src/hooks/useLocalStorage.ts @@ -0,0 +1,22 @@ +const useLocalStorage = () => { + const getItem = (key: string) => { + const item = localStorage.getItem(key) + return item ? JSON.parse(item) : null + } + + const setItem = (key: string, value: any) => { + localStorage.setItem(key, JSON.stringify(value)) + } + + const removeItem = (key: string) => { + localStorage.removeItem(key) + } + + return { + getItem, + setItem, + removeItem, + } +} + +export default useLocalStorage \ No newline at end of file