Skip to content

Commit

Permalink
✨ feat: server render시 userInfo null인 경우 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
chaaerim committed Jan 19, 2024
1 parent 7003a05 commit 8dc3104
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/app/(BackHeader)/my-page/@toast/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ const Toast = () => {

useEffect(() => {
setToastData(getSavedToastInfo());
console.log(getSavedToastInfo());
console.log(toastData);

clearSavedToast();
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
12 changes: 8 additions & 4 deletions src/app/(BackHeader)/my-page/@userInfo/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,30 @@ import { useRouter } from 'next/navigation';
import { ICON_URL } from '@/common';
import { Text } from '@/common/components/Text';

import { SkeletonUserInfo } from '../_components/SkeletonUserInfo.tsx';
import { useSuspenseUserInfoQuery } from '../_lib/hooks/useSuspenseUserInfoQuery';

const UserInfo = () => {
const router = useRouter();
const accessToken = getCookie('accessToken');
const { data: user } = useSuspenseUserInfoQuery(accessToken as string);
const { data: userInfo } = useSuspenseUserInfoQuery(accessToken as string);

if (!userInfo) {
return <SkeletonUserInfo />;
}
return (
<div className="w-full flex-col items-center pt-20px text-center">
<div className="mx-auto mb-24px h-96px w-96px overflow-hidden rounded-full">
<Image
src={user ? user.profileImageUrl : ICON_URL.EMOJI_BASE_GRAY}
src={userInfo ? userInfo.profileImageUrl : ICON_URL.EMOJI_BASE_GRAY}
alt="프로필 이미지"
width={96}
height={96}
/>
</div>
<div className="mb-8px flex h-24px w-full justify-center">
<Text typo="headingL" color="gray10">
{user?.nickname}
{userInfo?.nickname}
</Text>
<Image
className="ml-4px"
Expand All @@ -39,7 +43,7 @@ const UserInfo = () => {
</div>
<div className="h-24px">
<Text typo="body" color="gray40">
{user?.email}
{userInfo?.email}
</Text>
</div>
</div>
Expand Down

0 comments on commit 8dc3104

Please sign in to comment.