diff --git a/src/app/util.js b/src/app/util.js index 58606f64..b2cb2214 100644 --- a/src/app/util.js +++ b/src/app/util.js @@ -312,8 +312,11 @@ export function useFetch(url, { responseType, skip, ...fetchOptions }) { let storageListeners = []; export function useLocalStorage(key, initialValue) { const loadValue = React.useCallback(() => { + if (typeof localStorage === "undefined") { + return initialValue; + } try { - const item = window.localStorage.getItem(key); + const item = localStorage.getItem(key); return item ? JSON.parse(item) : initialValue; } catch (error) { console.error(error);