diff --git a/src/components/common/Header.tsx b/src/components/common/Header.tsx index dee7771..11d975e 100644 --- a/src/components/common/Header.tsx +++ b/src/components/common/Header.tsx @@ -1,7 +1,5 @@ -'use client' - -import dynamic from 'next/dynamic' 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' @@ -32,6 +30,12 @@ const Header = () => { } }, [pathname]) + useEffect(() => { + if (state === 'hasValue' && userInfo) { + // 사용자 정보가 로드된 후에 헤더를 다시 렌더링 + } + }, [state, userInfo]) + const handleCategoryClick = (path: string) => { if (!userInfo) { showToast('로그인이 필요한 서비스입니다') diff --git a/src/service/user/LoadUserInfo.tsx b/src/service/user/LoadUserInfo.tsx index b8a1480..85e098b 100644 --- a/src/service/user/LoadUserInfo.tsx +++ b/src/service/user/LoadUserInfo.tsx @@ -12,7 +12,9 @@ const LoadUserInfo = () => { const fetchUserInfo = async () => { try { const response = await UserService.fetchUserInfo() - setUserInfo(response.data) + if (response.data) { + setUserInfo(response.data) + } } catch (error) { console.error('Failed to load user info:', error) }