Skip to content

Commit deaed52

Browse files
committed
refactor(#43): Suspense 기반 로딩 처리로 변경 및 ProfileSkeleton 적
1 parent 248e9af commit deaed52

File tree

4 files changed

+55
-35
lines changed

4 files changed

+55
-35
lines changed
Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,23 @@
11
"use client";
22

3-
import { useQuery } from "@tanstack/react-query";
3+
import { useSuspenseQuery } from "@tanstack/react-query";
44

55
import { memberQueryOptions } from "@/app/member/_api";
6-
import Bapurit from "@/assets/logo/front-bapurit.svg";
7-
import { HStack, VStack } from "@/components/ui/Stack";
86
import { Text } from "@/components/ui/Text";
97

10-
import * as styles from "./Profile.css";
8+
import { ProfileLayout } from "./ProfileLayout";
119

1210
export const Profile = () => {
13-
const { data: member, isLoading } = useQuery(memberQueryOptions);
14-
15-
// TODO: 로딩 스피너 or 스켈레톤 정해지면 수정
16-
if (isLoading) {
17-
return (
18-
<HStack gap={16} className={styles.wrapper}>
19-
<div className={styles.imageBackground}>
20-
<Bapurit width={61} height={61} />
21-
</div>
22-
<VStack justify='center' gap={4}>
23-
<Text typo='title2Sb' color='neutral.10'>
24-
불러오는 중...
25-
</Text>
26-
</VStack>
27-
</HStack>
28-
);
29-
}
11+
const { data: member } = useSuspenseQuery(memberQueryOptions);
3012

3113
return (
32-
<HStack gap={16} className={styles.wrapper}>
33-
<div className={styles.imageBackground}>
34-
<Bapurit width={61} height={61} />
35-
</div>
36-
<VStack justify='center' gap={4}>
37-
<Text typo='title2Sb' color='neutral.10'>
38-
{member?.nickname}
39-
</Text>
40-
<Text typo='caption1Md' color='neutral.50'>
41-
{member?.email}
42-
</Text>
43-
</VStack>
44-
</HStack>
14+
<ProfileLayout>
15+
<Text typo='title2Sb' color='neutral.10'>
16+
{member.nickname}
17+
</Text>
18+
<Text typo='caption1Md' color='neutral.50'>
19+
{member.email}
20+
</Text>
21+
</ProfileLayout>
4522
);
4623
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"use client";
2+
3+
import { type ReactNode } from "react";
4+
5+
import Bapurit from "@/assets/logo/front-bapurit.svg";
6+
import { HStack, VStack } from "@/components/ui/Stack";
7+
8+
import * as styles from "./Profile.css";
9+
10+
export type ProfileLayoutProps = {
11+
children: ReactNode;
12+
};
13+
14+
export const ProfileLayout = ({ children }: ProfileLayoutProps) => {
15+
return (
16+
<HStack gap={16} className={styles.wrapper}>
17+
<div className={styles.imageBackground}>
18+
<Bapurit width={61} height={61} />
19+
</div>
20+
<VStack justify='center' gap={8}>
21+
{children}
22+
</VStack>
23+
</HStack>
24+
);
25+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Skeleton } from "@/components/ui/Skeleton";
2+
import { radius } from "@/styles";
3+
4+
import { ProfileLayout } from "./ProfileLayout";
5+
6+
export const ProfileSkeleton = () => {
7+
return (
8+
<ProfileLayout>
9+
<Skeleton width={80} height={20} radius={radius[40]} />
10+
<Skeleton width={160} height={20} radius={radius[40]} />
11+
</ProfileLayout>
12+
);
13+
};

src/app/member/profile/page.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
import { Suspense } from "react";
2+
13
import { VStack } from "@/components/ui/Stack";
24

35
import { Banner } from "./_components/Banner";
46
import { MenuList } from "./_components/MenuList";
57
import { Profile } from "./_components/Profile";
8+
import { ProfileSkeleton } from "./_components/Profile/ProfileSkeleton";
69

710
export default function ProfilePage() {
811
return (
912
<VStack>
10-
<Profile />
13+
<Suspense fallback={<ProfileSkeleton />}>
14+
<Profile />
15+
</Suspense>
1116
<Banner />
1217
<MenuList />
1318
</VStack>

0 commit comments

Comments
 (0)