Skip to content

Commit

Permalink
DN-4: Added as dep.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereckmezquita committed Jul 16, 2024
1 parent dd48952 commit f75d9b6
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions client/src/context/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,20 @@ export const AuthProvider: React.FC<React.PropsWithChildren<{}>> = ({
const [user, setUser] = useState<User | null>(null);
const [loading, setLoading] = useState(true);

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);
}
};
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(() => {
checkAuth();
}, []);
}, [checkAuth]);

const login = async (email: string, password: string) => {
const response = await api.post<{ user: User }>('/auth/login', {
Expand Down

0 comments on commit f75d9b6

Please sign in to comment.