Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

fix: check 'window' object using typeof (#1470)

Fahad Khan5a12f145b795
diff --git a/apps/web/src/utils/useLocalStorage.ts b/apps/web/src/utils/useLocalStorage.ts
index 6792e311..4966ed9d 100644
--- a/apps/web/src/utils/useLocalStorage.ts
+++ b/apps/web/src/utils/useLocalStorage.ts
@@ -3,7 +3,7 @@ import { useState } from 'react';
export function useLocalStorage(key: string, initialValue: string): [string, (v: string) => void] {
const [storedValue, setStoredValue] = useState<string>(() => {
try {
- if (window !== undefined) {
+ if (typeof window !== 'undefined') {
return window.localStorage.getItem(key) || initialValue;
}
return initialValue;