Skip to content

Commit

Permalink
Merge pull request #4 from GihoKo/dev
Browse files Browse the repository at this point in the history
refactor: 필요없는 코드 삭제
  • Loading branch information
GihoKo authored Jul 15, 2024
2 parents 0be3b98 + a61d6c7 commit f79dc3d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
24 changes: 12 additions & 12 deletions src/pages/Main/MainPage.hook.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// hooks
import useRenewTokens from '@/apis/hooks/useRenewTokens';
import { useApplicationAuthTokenStore } from '@/store/useAuthStore';
import { useEffect } from 'react';
// // hooks
// import useRenewTokens from '@/apis/hooks/useRenewTokens';
// import { useApplicationAuthTokenStore } from '@/store/useAuthStore';
// import { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';

export default function useMainPage() {
const navigate = useNavigate();
const { setAccessToken } = useApplicationAuthTokenStore();
const { data, isLoading, isSuccess, isError } = useRenewTokens();
// const { setAccessToken } = useApplicationAuthTokenStore();
// const { data, isLoading, isSuccess, isError } = useRenewTokens();

useEffect(() => {
if (isSuccess) {
setAccessToken(data.accessToken);
}
}, [data]);
// useEffect(() => {
// if (isSuccess) {
// setAccessToken(data.accessToken);
// }
// }, [data]);

return { isLoading, isError, navigate };
return { navigate };
}
12 changes: 2 additions & 10 deletions src/pages/Main/MainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import styled from 'styled-components';

// hooks
import useMainPage from './MainPage.hook';
// import useMainPage from './MainPage.hook';

// components
import Header from './_compoenets/Header/Header';
Expand All @@ -11,15 +11,7 @@ import { Outlet } from 'react-router-dom';

export default function MainPage() {
//logics
const { isLoading, isError, navigate } = useMainPage();

// view
if (isLoading) {
return <div>엑세스 토큰을 발급 중 입니다...</div>;
}
if (isError) {
navigate('/signIn');
}
// const { navigate } = useMainPage();

return (
<Wrapper>
Expand Down

0 comments on commit f79dc3d

Please sign in to comment.