fix: prevent useAuth infinite loop causing rate limit storms

checkAuth was defined as a plain function and used as a useEffect
dependency, causing it to fire on every render. Moved it inside the
effect with an empty dependency array so it runs once on mount.
This commit is contained in:
Siddharth Kumar Sah
2026-03-26 01:10:51 +08:00
parent 200e7d10c1
commit 3b4f522bf4
+3 -3
View File
@@ -14,9 +14,6 @@ export function useAuth(): AuthState {
}); });
useEffect(() => { useEffect(() => {
checkAuth();
}, [checkAuth]);
async function checkAuth() { async function checkAuth() {
try { try {
// Check if auth is enabled // Check if auth is enabled
@@ -51,5 +48,8 @@ export function useAuth(): AuthState {
} }
} }
checkAuth();
}, []);
return state; return state;
} }