Skip to content

Commit

Permalink
fix: 비로그인뷰가 잠시보이는 현상 임시 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
asdf99245 committed Aug 14, 2023
1 parent 8a219d1 commit 5acecf7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/shared/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function Avatar({
<div
className={cn(
'tw-relative tw-h-20 tw-w-20 tw-overflow-hidden tw-rounded-full',
isLogin && 'tw-cursor-pointer',
// isLogin && 'tw-cursor-pointer',
)}
onClick={handleEditProfile}
>
Expand Down
11 changes: 7 additions & 4 deletions src/hooks/useLogin.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { useEffect, useState } from 'react';
import { useState } from 'react';
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';

export function useLogin() {
const [login, setLogin] = useState(false);
useEffect(() => {
const [login, setLogin] = useState<boolean | null>(null);

useIsomorphicLayoutEffect(() => {
const user_id = localStorage.getItem('userId');
if (user_id) {
setLogin(true);
return;
}
setLogin(false);
}, []);

return { login };
Expand Down
1 change: 1 addition & 0 deletions src/pages/user/[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default function User({
dispatch({ type: 'OPEN_PROFILE_MODAL' });
};

if (isLogin === null) return null;
if (isLoading) return <div>로딩중...</div>;
if (isError) return <div>에러 ㅋ</div>;

Expand Down

0 comments on commit 5acecf7

Please sign in to comment.