From b531a840e8d77ac1297df7d5885d214d5edd2c43 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Tue, 24 Feb 2026 07:35:50 +0000 Subject: [PATCH] fix: refactor logout function to use useCallback for improved performance --- frontend/src/context/AuthContext.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/context/AuthContext.tsx b/frontend/src/context/AuthContext.tsx index e09a0227..44a9c333 100644 --- a/frontend/src/context/AuthContext.tsx +++ b/frontend/src/context/AuthContext.tsx @@ -109,7 +109,7 @@ export const AuthProvider: FC<{ children: ReactNode }> = ({ children }) => { } }, [fetchSessionUser]); - const logout = async () => { + const logout = useCallback(async () => { invalidateAuthRequests(); localStorage.removeItem('charon_auth_token'); setAuthToken(null); @@ -121,7 +121,7 @@ export const AuthProvider: FC<{ children: ReactNode }> = ({ children }) => { } catch (error) { console.error("Logout failed", error); } - }; + }, [invalidateAuthRequests]); const changePassword = async (oldPassword: string, newPassword: string) => { try { @@ -174,7 +174,7 @@ export const AuthProvider: FC<{ children: ReactNode }> = ({ children }) => { window.removeEventListener(event, handleActivity); }); }; - }, [user]); + }, [user, logout]); return (