Skip to content

Commit

Permalink
Merge pull request #119 from LikeLionHGU/jonghyun_feat/#115
Browse files Browse the repository at this point in the history
fix: 무한 로딩 버그 수정
  • Loading branch information
dkrehd0519 authored Aug 5, 2024
2 parents eaafbd8 + c690146 commit bcb78ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const AxiosInterceptor = () => {
console.log("Axios interceptor caught an error:", error); // 로그 추가
setCsrfToken(null);
setUserTokenState({ isLogin: false });
navigate("/");
navigate("/", { replace: true }); // 리다이렉션
}
return Promise.reject(error);
}
Expand Down
8 changes: 5 additions & 3 deletions src/loginPage/LoginPage.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Link, useNavigate } from "react-router-dom";
import { useRecoilValue } from "recoil";
import styled from "styled-components";
import { UserTokenState } from "../atom/atom";
import { tokenState, UserTokenState } from "../atom/atom";
import { useEffect } from "react";

const Wrapper = styled.div`
Expand Down Expand Up @@ -29,12 +29,14 @@ const GoogleLoginBtn = styled.div`
const LoginPage = () => {
const navigate = useNavigate();
const UserToken = useRecoilValue(UserTokenState);
const Token = useRecoilValue(tokenState);

useEffect(() => {
if (UserToken !== false) {
// UserToken이 null이 아니고, false가 아닌 경우에만 navigate 호출
if (Token !== null && UserToken !== false) {
navigate(`/HomePage`);
}
}, [UserToken]);
}, [UserToken, navigate]);
const handleGoogleLogin = () => {
// 구글 로그인 화면으로 이동시키기
window.location.href = `${process.env.REACT_APP_HOST_URL}/oauth2/authorization/google`;
Expand Down

0 comments on commit bcb78ad

Please sign in to comment.