Skip to content

Commit

Permalink
feat: 댓글이 없는 경우 id를 읽어올 수 없는 문제 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
xodms0309 committed Oct 16, 2023
1 parent 778e9f7 commit bdc7fcd
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const useInfiniteRecipeCommentQuery = (recipeId: number) => {
({ pageParam = { lastId: 0, totalElements: null } }) => fetchRecipeComments(pageParam, recipeId),
{
getNextPageParam: (prevResponse: CommentResponse) => {
const lastId = prevResponse.comments[prevResponse.comments.length - 1].id;
const lastId = prevResponse.comments.length ? prevResponse.comments[prevResponse.comments.length - 1].id : 0;
const totalElements = prevResponse.totalElements;
const lastCursor = { lastId: lastId, totalElements: totalElements };
return prevResponse.hasNext ? lastCursor : undefined;
Expand Down

0 comments on commit bdc7fcd

Please sign in to comment.