@@ -10,6 +10,7 @@ import { useNavigate, useParams } from 'react-router';
1010import { useInView } from 'react-intersection-observer' ;
1111import EmotionRecordCardList from '@/pages/userprofile/components/EmotionRecordCardList' ;
1212import { useUserStore } from '@/store/userStore' ;
13+ import Loading from '@/components/loading/Loading' ;
1314
1415// 마이페이지 / 유저페이지 동시에 사용
1516function 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