Skip to content

Commit

Permalink
feat: post type 탭 suspesne=false
Browse files Browse the repository at this point in the history
  • Loading branch information
wildcatco committed Aug 27, 2023
1 parent c96ff2c commit fcf75e7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/features/posts/queries/useGetPosts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ export function useGetPosts({
initialPostId,
userId,
type,
suspense = true,
}: {
initialPostId?: number;
userId?: number;
type: POST_TYPE;
suspense?: boolean;
}) {
const { data, ...queryInfo } = useInfiniteQuery({
queryKey: ['posts', { initialPostId, userId, type }],
Expand All @@ -50,7 +52,7 @@ export function useGetPosts({
type === POST_TYPE.PARTICIPATED ? userId : undefined,
}),
getNextPageParam: (lastPage) => lastPage.meta.nextId,
suspense: true,
suspense,
staleTime: 1000 * 60 * 5, // 5분
});
const { hasNextPage, fetchNextPage } = queryInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ export function PostTypeTabList({
const { totalCount: myPostsCount } = useGetPosts({
userId: user?.id,
type: POST_TYPE.MY,
suspense: false,
});
const { totalCount: participatedPostsCount } = useGetPosts({
userId: user?.id,
type: POST_TYPE.PARTICIPATED,
suspense: false,
});

const handleTabSelect = (postType: POST_TYPE) => {
Expand Down
10 changes: 4 additions & 6 deletions src/pages/user/UserPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ export default function UserPage() {
<UserPageHeader />
<Divider className={'my-[1.9rem]'} />
<main className={'flex h-full min-h-0 w-full flex-col'}>
<Suspense fallback={'fuck'}>
<PostTypeTabList
selectedPostType={selectedPostType}
onSelect={handlePostTypeSelect}
/>
</Suspense>
<PostTypeTabList
selectedPostType={selectedPostType}
onSelect={handlePostTypeSelect}
/>
<Spacing size={'2.1rem'} />
<div
id={selectedPostType}
Expand Down

0 comments on commit fcf75e7

Please sign in to comment.