diff --git a/src/hooks/account/useAuth.ts b/src/hooks/account/useAuth.ts index 0e12199..de75eda 100644 --- a/src/hooks/account/useAuth.ts +++ b/src/hooks/account/useAuth.ts @@ -21,24 +21,22 @@ export const useAuth = () => { const { user, isLoading } = useUserQuery(); const [isActive, setIsActive] = useState(undefined); - useEffect(() => { - if (!isLoading && user !== undefined) { - setIsActive(useIsActive(user)); - } - }, [isLoading, user]); - const kakaoMutation = useMutation(getAccessToken, { onSuccess: (data: any) => { - if (isActive !== undefined) { - setAccessToken(data.accessToken); - isActive ? router.push("/") : router.push("/sign-up/default"); - } + setAccessToken(data.accessToken); }, onError: (error: any) => { alert(error); } }); + useEffect(() => { + if (!kakaoMutation.isLoading && !isLoading && user !== undefined) { + setIsActive(useIsActive(user)); + isActive ? router.push("/") : router.push("/sign-up/default"); + } + }, [kakaoMutation.isLoading, isLoading, user, isActive, router]); + return { kakaoMutation };