From dd4895221ed2ecaa6b972c6d4ae1084ccb6abe0b Mon Sep 17 00:00:00 2001 From: dereckmezquita Date: Mon, 15 Jul 2024 19:22:48 -0500 Subject: [PATCH] DN-4: Avoid deps. --- client/src/context/AuthContext.tsx | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/client/src/context/AuthContext.tsx b/client/src/context/AuthContext.tsx index c16801346e..503d9f595d 100644 --- a/client/src/context/AuthContext.tsx +++ b/client/src/context/AuthContext.tsx @@ -31,18 +31,20 @@ export const AuthProvider: React.FC> = ({ const [user, setUser] = useState(null); const [loading, setLoading] = useState(true); - const checkAuth = async () => { - try { - const response = await api.get<{ user: User }>('/auth/user-info'); - setUser(response.data.user); - } catch (error) { - setUser(null); - } finally { - setLoading(false); - } - }; - useEffect(() => { + const checkAuth = async () => { + try { + const response = await api.get<{ user: User }>( + '/auth/user-info' + ); + setUser(response.data.user); + } catch (error) { + setUser(null); + } finally { + setLoading(false); + } + }; + checkAuth(); }, []);