Skip to content

Commit

Permalink
refactor: useFetchSession훅 isError시 null 값 전달하도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
JW-Ahn0 committed Jan 8, 2025
1 parent 9e12838 commit 81f5139
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/hooks/useFetchSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const useFetchSession = () => {
retry: false,
});
return {
sessionUser: data,
sessionUser: isError ? null : data,
isLoading,
isError,
};
Expand Down
4 changes: 2 additions & 2 deletions src/pages/guards/LoginGuard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ interface ILoginGuardProps {
* 로그인한 사용자가 로그인 페이지 접근 시 처리
*/
export const LoginGuard = ({ children }: ILoginGuardProps) => {
const { sessionUser, isLoading, isError } = useFetchSession();
const { sessionUser, isLoading } = useFetchSession();

if (isLoading) {
return null;
}

if (!isError && sessionUser) {
if (sessionUser) {
return <Navigate to="/" replace />;
}

Expand Down

0 comments on commit 81f5139

Please sign in to comment.