From 4a597322818380a7f99c8598d80798227caba6cf Mon Sep 17 00:00:00 2001 From: Jeff Sieu Date: Tue, 8 Nov 2022 02:22:22 +0800 Subject: [PATCH] [questions][ui] show load more only when more than one page --- .../components/questions/PaginationLoadMoreButton.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/portal/src/components/questions/PaginationLoadMoreButton.tsx b/apps/portal/src/components/questions/PaginationLoadMoreButton.tsx index 0d6a55be..dcc5fbd4 100644 --- a/apps/portal/src/components/questions/PaginationLoadMoreButton.tsx +++ b/apps/portal/src/components/questions/PaginationLoadMoreButton.tsx @@ -9,8 +9,15 @@ export default function PaginationLoadMoreButton( props: PaginationLoadMoreButtonProps, ) { const { - query: { hasNextPage, isFetchingNextPage, fetchNextPage }, + query: { data, hasNextPage, isFetchingNextPage, fetchNextPage }, } = props; + + const isOnlyOnePage = data?.pages.length === 1; + + if (isOnlyOnePage && !hasNextPage) { + return null; + } + return (