diff --git a/src/apis/queries.ts b/src/apis/queries.ts index 425830ec..fead4ccf 100644 --- a/src/apis/queries.ts +++ b/src/apis/queries.ts @@ -47,6 +47,10 @@ const queries = createQueryKeyStore({ queryKey: ['epigramComments', epigramId], queryFn: ({ pageParam }: { pageParam?: number }) => getEpigramComments({ id: epigramId, limit: 3, cursor: pageParam }), }), + getCommentList: (request: CommentRequestType) => ({ + queryKey: ['epigramComments', request] as const, + queryFn: ({ pageParam }: { pageParam: number | undefined }) => getEpigramComments({ ...request, cursor: pageParam }), + }), getMyComments: (request: CommentRequestType) => ({ queryKey: ['myEpigramComments', request], queryFn: () => getMyEpigramComments(request), diff --git a/src/hooks/useEpigramCommentsQueryHook.ts b/src/hooks/useEpigramCommentsQueryHook.ts index f1db908b..23945603 100644 --- a/src/hooks/useEpigramCommentsQueryHook.ts +++ b/src/hooks/useEpigramCommentsQueryHook.ts @@ -1,12 +1,14 @@ -import { InfiniteData, useInfiniteQuery } from '@tanstack/react-query'; -import { CommentResponseType } from '@/schema/comment'; +// hooks/useEpigramCommentHook.ts + +import { useInfiniteQuery } from '@tanstack/react-query'; import queries from '@/apis/queries'; +import { CommentResponseType } from '@/schema/comment'; const useEpigramCommentsQuery = (epigramId: number) => useInfiniteQuery>({ ...queries.epigramComment.getComments(epigramId), initialPageParam: undefined, - getNextPageParam: (lastPage) => lastPage.nextCursor ?? undefined, + getNextPageParam: (lastPage: CommentResponseType) => lastPage.nextCursor ?? undefined, }); export default useEpigramCommentsQuery;