diff --git a/apps/app/hooks/use-local-storage.tsx b/apps/app/hooks/use-local-storage.tsx index 8e2877a65ec..f6439ec1b91 100644 --- a/apps/app/hooks/use-local-storage.tsx +++ b/apps/app/hooks/use-local-storage.tsx @@ -1,8 +1,13 @@ import { useState, useEffect, useCallback } from "react"; const getValueFromLocalStorage = (key: string, defaultValue: any) => { - const value = window.localStorage.getItem(key); - return value ? JSON.parse(value) : defaultValue; + try { + const item = window.localStorage.getItem(key); + return item ? JSON.parse(item) : defaultValue; + } catch (error) { + window.localStorage.removeItem(key); + return defaultValue; + } }; const useLocalStorage = (key: string, initialValue: T) => {