Skip to content

Commit 7a5ef2b

Browse files
committed
Review suggestions
Signed-off-by: brookewp <[email protected]>
1 parent 1ec7391 commit 7a5ef2b

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

inc/Validation/ConfigSchemas.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,8 @@ private static function generate_http_query_config_schema(): array {
288288
'pagination_schema' => Types::nullable(
289289
Types::object( [
290290
// This field provides an integer representing the total number of
291-
// items available in paginated results. This field must be defined
292-
// in order present to enable pagination support of any type,
293-
// including cursor-based pagination.
291+
// items available in paginated results. Either this field or
292+
// `has_next_page` must be defined in order to enable
294293
'total_items' => Types::nullable(
295294
Types::object( [
296295
'name' => Types::nullable( Types::string() ),

src/blocks/remote-data-container/components/item-list/ItemList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export function ItemList( props: ItemListProps ) {
162162
onChangeView={ onChangeView }
163163
paginationInfo={ {
164164
totalItems: totalItems ?? data.length,
165-
totalPages: totalPages ?? ( hasNextPage ? page + 1 : page - 1 ),
165+
totalPages: totalPages ?? ( hasNextPage ? page + 1 : page - 1 ) ?? 1,
166166
} }
167167
search={ supportsSearch }
168168
view={ view }

src/blocks/remote-data-container/hooks/usePaginationVariables.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function usePaginationVariables( {
3636
initialPerPage,
3737
inputVariables,
3838
}: UsePaginationVariablesInput ): UsePaginationVariables {
39-
const [ paginationData, setPaginationData ] = useState< RemoteDataPagination >( {} );
39+
const [ paginationData, setPaginationData ] = useState< RemoteDataPagination >();
4040
const [ page, setPage ] = useState< number >( initialPage );
4141
const [ perPage, setPerPage ] = useState< number | null >( initialPerPage ?? null );
4242

types/remote-data.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ interface InnerBlockContext {
33
}
44

55
interface RemoteDataPagination {
6-
hasNextPage?: boolean;
76
cursorNext?: string;
87
cursorPrevious?: string;
8+
hasNextPage?: boolean;
99
totalItems?: number;
1010
}
1111

0 commit comments

Comments
 (0)