Skip to content

Commit b52b10d

Browse files
authored
Merge pull request #206 from prgrms-web-devcourse-final-project/feat/205-mypage-loading
[feat] 마이페이지 로딩 추가
2 parents 6798908 + c8fd002 commit b52b10d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/pages/userprofile/UserProfile.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { useNavigate, useParams } from 'react-router';
1010
import { useInView } from 'react-intersection-observer';
1111
import EmotionRecordCardList from '@/pages/userprofile/components/EmotionRecordCardList';
1212
import { useUserStore } from '@/store/userStore';
13+
import Loading from '@/components/loading/Loading';
1314

1415
// 마이페이지 / 유저페이지 동시에 사용
1516
function UserProfile({ isMyPage }: { isMyPage: boolean }) {
@@ -24,7 +25,7 @@ function UserProfile({ isMyPage }: { isMyPage: boolean }) {
2425
const { ref, inView } = useInView();
2526

2627
// 유저 정보 가져오기
27-
const { data: userData } = useQuery({
28+
const { data: userData, isLoading: isUserLoading } = useQuery({
2829
queryKey: isMyPage ? ['myPage'] : ['userPage'], // 유저페이지 캐싱할때 추가적으로 넣어주자
2930
queryFn: () => (isMyPage ? getMyProfile() : getUserProfile(userId as string)),
3031
});
@@ -38,6 +39,7 @@ function UserProfile({ isMyPage }: { isMyPage: boolean }) {
3839

3940
const {
4041
data: emotionRecords,
42+
isLoading: isEmotionLoading,
4143
fetchNextPage,
4244
hasNextPage,
4345
isFetchingNextPage,
@@ -144,8 +146,8 @@ function UserProfile({ isMyPage }: { isMyPage: boolean }) {
144146
}
145147
}, [inView]);
146148

147-
return (
148-
<div className="w-full">
149+
return (
150+
<>
149151
<div className="flex flex-col items-center w-full h-full gap-4 py-4">
150152
<div className="flex flex-col items-center">
151153
<span className="h3-b">{userData?.data?.nickname}</span>
@@ -175,7 +177,8 @@ function UserProfile({ isMyPage }: { isMyPage: boolean }) {
175177
handleEdit={handleEdit}
176178
/>
177179
)}
178-
</div>
180+
{(isUserLoading || isEmotionLoading) && <Loading />}
181+
</>
179182
);
180183
}
181184

0 commit comments

Comments
 (0)