From a0edc5587a573ef73d178044e1073d86c338ff44 Mon Sep 17 00:00:00 2001 From: parkyejin Date: Tue, 3 Sep 2024 02:05:15 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=83=88?= =?UTF-8?q?=EB=A1=9C=EA=B3=A0=EC=B9=A8=20=EC=97=90=EB=9F=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/Header.tsx | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/components/common/Header.tsx b/src/components/common/Header.tsx index 18e5357..220ab35 100644 --- a/src/components/common/Header.tsx +++ b/src/components/common/Header.tsx @@ -4,7 +4,7 @@ import React, { useState, useEffect } from 'react' import dynamic from 'next/dynamic' import Image from 'next/image' import { useToast } from '@/hooks/useToast' -import { useRecoilValueLoadable } from 'recoil' +import { useRecoilValue } from 'recoil' import { userInfoState } from '@/recoil/UserInfo' import { useRouter, usePathname } from 'next/navigation' import Button from './Button' @@ -22,9 +22,9 @@ const Header = () => { const pathname = usePathname() const router = useRouter() const [selected, setSelected] = useState(null) - const userInfoLoadable = useRecoilValueLoadable(userInfoState) - const { state, contents: userInfo } = userInfoLoadable + const userInfo = useRecoilValue(userInfoState) const { showToast } = useToast() + console.log('userInfo:', userInfo) useEffect(() => { if (pathname) { @@ -32,12 +32,6 @@ const Header = () => { } }, [pathname]) - useEffect(() => { - if (state === 'hasValue' && userInfo) { - // 사용자 정보가 로드된 후에 헤더를 다시 렌더링 - } - }, [state, userInfo]) - const handleCategoryClick = (path: string) => { if (!userInfo) { showToast('로그인이 필요한 서비스입니다') @@ -52,10 +46,6 @@ const Header = () => { router.push(path) } - if (state === 'loading') { - return
로딩 중...
- } - return ( <>
@@ -73,15 +63,15 @@ const Header = () => { onClick={() => router.push('/')} className="cursor-pointer" /> - {!userInfo ? ( + {userInfo !== null ? ( + + ) : (