From 53b63ac27c2275262db9a04be02210a3287aa71d Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Fri, 1 Dec 2023 19:34:58 +0100 Subject: refactor(pages): refine Blog pages * replace usePostsList with useArticlesList to keep names coherent * remove useIsMounted hook * rewrite useRedirection hook * add redirect in getStaticProps to avoid unecessary fetching * move Pagination component in a noscript tag * use hooks to refresh thematics and topics lists * complete Cypress tests --- src/utils/hooks/use-pagination/use-pagination.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/utils/hooks/use-pagination/use-pagination.ts') diff --git a/src/utils/hooks/use-pagination/use-pagination.ts b/src/utils/hooks/use-pagination/use-pagination.ts index 2a40aa4..29d5ba2 100644 --- a/src/utils/hooks/use-pagination/use-pagination.ts +++ b/src/utils/hooks/use-pagination/use-pagination.ts @@ -11,7 +11,7 @@ export type UsePaginationFetcherInput = GraphQLEdgesInput & { search?: string; }; -export type UsePaginationConfig = { +export type UsePaginationConfig = Pick & { /** * The initial data. */ @@ -86,6 +86,7 @@ export type UsePaginationReturn = { * @returns {UsePaginationReturn} An object with pagination data and helpers. */ export const usePagination = ({ + after, fallback, fetcher, perPage, @@ -97,12 +98,11 @@ export const usePagination = ({ return { first: perPage, - after: - pageIndex === 0 ? undefined : previousPageData?.pageInfo.endCursor, + after: pageIndex === 0 ? after : previousPageData?.pageInfo.endCursor, search: searchQuery, }; }, - [perPage, searchQuery] + [after, perPage, searchQuery] ); const { data, error, isLoading, isValidating, setSize, size } = -- cgit v1.2.3