mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
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:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user