Skip to content

Commit

Permalink
DN-4: Avoid deps.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereckmezquita committed Jul 16, 2024
1 parent ebb9479 commit dd48952
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions client/src/context/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,20 @@ export const AuthProvider: React.FC<React.PropsWithChildren<{}>> = ({
const [user, setUser] = useState<User | null>(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();
}, []);

Expand Down

0 comments on commit dd48952

Please sign in to comment.