-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix: 비로그인 내 프로필 페이지 컨탠츠 gap 수정 * fix: ErrorBoundary 제거 * refactor: 내 책장 프리뷰 query의 data값을 보장하도록 useQueryWithSuspense를 적용 * refactor: 불필요한 isSuccess 제거 및 LayoutShift 문제 해결 * chore: 불필요한 query 옵션 제거
- Loading branch information
Showing
8 changed files
with
66 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,14 @@ | ||
import QueryErrorBoundaryFallback from '@/v1/base/QueryErrorBoundaryFallback'; | ||
import { QueryErrorResetBoundary } from '@tanstack/react-query'; | ||
import { Suspense } from 'react'; | ||
import { ErrorBoundary } from 'react-error-boundary'; | ||
import type { APIUser } from '@/types/user'; | ||
|
||
import MyProfileBookshelfContainer from './MyProfileBookshelfContainer'; | ||
import UserProfileBookshelfContainer from './UserProfileBookshelfContainer'; | ||
import useMounted from '@/hooks/useMounted'; | ||
import Loading from '@/v1/base/Loading'; | ||
|
||
const ProfileBookShelf = ({ userId }: { userId: 'me' | APIUser['userId'] }) => { | ||
const mounted = useMounted(); | ||
|
||
if (!mounted) return null; | ||
|
||
return ( | ||
<QueryErrorResetBoundary> | ||
{({ reset }) => ( | ||
<ErrorBoundary | ||
onReset={reset} | ||
fallbackRender={({ resetErrorBoundary }) => ( | ||
<QueryErrorBoundaryFallback | ||
resetErrorBoundary={resetErrorBoundary} | ||
/> | ||
)} | ||
> | ||
<Suspense fallback={<ProfileBookShelfSkeleton />}> | ||
{userId === 'me' ? ( | ||
<MyProfileBookshelfContainer /> | ||
) : ( | ||
<UserProfileBookshelfContainer userId={userId} /> | ||
)} | ||
</Suspense> | ||
</ErrorBoundary> | ||
)} | ||
</QueryErrorResetBoundary> | ||
return userId === 'me' ? ( | ||
<MyProfileBookshelfContainer /> | ||
) : ( | ||
<UserProfileBookshelfContainer userId={userId} /> | ||
); | ||
}; | ||
|
||
export default ProfileBookShelf; | ||
|
||
const ProfileBookShelfSkeleton = () => { | ||
return ( | ||
<div className="flex animate-pulse flex-col gap-[2rem]"> | ||
<div className="h-[2.7rem] w-[5rem] bg-placeholder" /> | ||
|
||
<div className="flex h-[13.2rem] items-center justify-center"> | ||
<Loading /> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,44 @@ | ||
import useMounted from '@/hooks/useMounted'; | ||
import SSRSafeSuspense from '@/components/SSRSafeSuspense'; | ||
|
||
import { APIUser } from '@/types/user'; | ||
import QueryErrorBoundaryFallback from '@/v1/base/QueryErrorBoundaryFallback'; | ||
import { QueryErrorResetBoundary } from '@tanstack/react-query'; | ||
import { Suspense } from 'react'; | ||
import { ErrorBoundary } from 'react-error-boundary'; | ||
|
||
import Skeleton from '@/v1/base/Skeleton'; | ||
import ProfileGroupContainer from './ProfileGroupContainer'; | ||
|
||
const ProfileGroup = ({ userId }: { userId: 'me' | APIUser['userId'] }) => { | ||
const mounted = useMounted(); | ||
|
||
if (!mounted) return null; | ||
|
||
return ( | ||
<QueryErrorResetBoundary> | ||
{({ reset }) => ( | ||
<ErrorBoundary | ||
onReset={reset} | ||
fallbackRender={({ resetErrorBoundary }) => ( | ||
<QueryErrorBoundaryFallback | ||
resetErrorBoundary={resetErrorBoundary} | ||
/> | ||
)} | ||
> | ||
<Suspense fallback={<ProfileGroupSkeleton />}> | ||
<ProfileGroupContainer userId={userId} /> | ||
</Suspense> | ||
</ErrorBoundary> | ||
)} | ||
</QueryErrorResetBoundary> | ||
<SSRSafeSuspense fallback={<ProfileGroupSkeleton />}> | ||
<ProfileGroupContainer userId={userId} /> | ||
</SSRSafeSuspense> | ||
); | ||
}; | ||
|
||
export default ProfileGroup; | ||
|
||
const ProfileGroupSkeleton = () => { | ||
return ( | ||
<div className="flex animate-pulse flex-col gap-[0.6rem]"> | ||
<div className="flex h-[2.7rem] w-[6rem] bg-placeholder" /> | ||
<div className="flex gap-[1rem] overflow-scroll"> | ||
<div className="flex flex-col gap-[0.5rem]"> | ||
<div className="h-[11.6rem] w-[10rem] bg-placeholder" /> | ||
<div className="h-[1.5rem] bg-placeholder" /> | ||
</div> | ||
<div className="flex flex-col gap-[0.5rem]"> | ||
<div className="h-[11.6rem] w-[10rem] bg-placeholder" /> | ||
<div className="h-[1.5rem]bg-placeholder" /> | ||
</div> | ||
<div className="flex flex-col gap-[0.5rem]"> | ||
<div className="h-[11.6rem] w-[10rem] bg-placeholder" /> | ||
<div className="h-[1.5rem] bg-placeholder" /> | ||
<Skeleton> | ||
<div className="flex flex-col gap-[1.5rem]"> | ||
<Skeleton.Text fontSize="2xlarge" width="6rem" /> | ||
<div className="flex gap-[1rem] overflow-scroll"> | ||
<div className="flex flex-col gap-[1rem]"> | ||
<Skeleton.Rect rounded="small" width="10rem" height="12.3rem" /> | ||
<Skeleton.Text fontSize="small" width="10rem" /> | ||
</div> | ||
<div className="flex flex-col gap-[1rem]"> | ||
<Skeleton.Rect rounded="small" width="10rem" height="12.3rem" /> | ||
<Skeleton.Text fontSize="small" width="10rem" /> | ||
</div> | ||
<div className="flex flex-col gap-[1rem]"> | ||
<Skeleton.Rect rounded="small" width="10rem" height="12.3rem" /> | ||
<Skeleton.Text fontSize="small" width="10rem" /> | ||
</div> | ||
<div className="flex flex-col gap-[1rem]"> | ||
<Skeleton.Rect rounded="small" width="10rem" height="12.3rem" /> | ||
<Skeleton.Text fontSize="small" width="10rem" /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</Skeleton> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,42 @@ | ||
import { ReactNode, Suspense } from 'react'; | ||
import type { APIUser } from '@/types/user'; | ||
|
||
import SSRSafeSuspense from '@/components/SSRSafeSuspense'; | ||
|
||
import Skeleton from '@/v1/base/Skeleton'; | ||
import MyProfileContainer from './MyProfileInfoContainer'; | ||
import UserProfileInfoContainer from './UserProfileInfoContainer'; | ||
import { QueryErrorResetBoundary } from '@tanstack/react-query'; | ||
import { ErrorBoundary } from 'react-error-boundary'; | ||
import type { APIUser } from '@/types/user'; | ||
import QueryErrorBoundaryFallback from '@/v1/base/QueryErrorBoundaryFallback'; | ||
import useMounted from '@/hooks/useMounted'; | ||
|
||
type ProfileInfoProps = { | ||
children?: ReactNode; | ||
userId: 'me' | APIUser['userId']; | ||
}; | ||
|
||
const ProfileInfo = ({ userId, children }: ProfileInfoProps) => { | ||
const mounted = useMounted(); | ||
|
||
if (!mounted) return null; | ||
|
||
const ProfileInfo = ({ userId }: ProfileInfoProps) => { | ||
return ( | ||
<QueryErrorResetBoundary> | ||
{({ reset }) => ( | ||
<ErrorBoundary | ||
onReset={reset} | ||
fallbackRender={({ resetErrorBoundary }) => ( | ||
<QueryErrorBoundaryFallback | ||
resetErrorBoundary={resetErrorBoundary} | ||
/> | ||
)} | ||
> | ||
<Suspense fallback={<ProfileInfoSkeleton />}> | ||
{userId === 'me' ? ( | ||
<MyProfileContainer /> | ||
) : ( | ||
<UserProfileInfoContainer userId={userId} /> | ||
)} | ||
{children && children} | ||
</Suspense> | ||
</ErrorBoundary> | ||
<SSRSafeSuspense fallback={<ProfileInfoSkeleton />}> | ||
{userId === 'me' ? ( | ||
<MyProfileContainer /> | ||
) : ( | ||
<UserProfileInfoContainer userId={userId} /> | ||
)} | ||
</QueryErrorResetBoundary> | ||
</SSRSafeSuspense> | ||
); | ||
}; | ||
|
||
export default ProfileInfo; | ||
|
||
const ProfileInfoSkeleton = () => { | ||
return ( | ||
<div className="mb-[2rem] flex animate-pulse flex-col gap-[2rem]"> | ||
<div className="flex gap-[0.8rem]"> | ||
<div className="h-[2.1rem] w-[3.8rem] rounded-lg bg-placeholder" /> | ||
<div className="h-[2.1rem] w-[7.6rem] rounded-lg bg-placeholder" /> | ||
</div> | ||
<div className="flex items-center gap-[1rem]"> | ||
<div className="h-[7rem] w-[7rem] rounded-full bg-placeholder" /> | ||
<div className="h-[2.7rem] w-[11rem] bg-placeholder" /> | ||
<Skeleton> | ||
<div className="mb-[2rem] flex flex-col gap-[2rem]"> | ||
<div className="flex gap-[0.8rem]"> | ||
<Skeleton.Rect width="3.8rem" height="2.1rem" /> | ||
<Skeleton.Rect width="10.4rem" height="2.1rem" /> | ||
</div> | ||
<div className="flex items-center gap-[1rem]"> | ||
<Skeleton.Circle size="large" /> | ||
<Skeleton.Text fontSize="2xlarge" width="18rem" /> | ||
</div> | ||
</div> | ||
</div> | ||
</Skeleton> | ||
); | ||
}; |