Functions
[usePagination(config)] ⇒ Array.<Object>
A React Hook that provides pagination logic.
Use this hook to implement components that need to navigate through paged data.
The current pagination state
Properties
Name
Type
Description
currentPage
NumberThe current page number
totalPages
NumberThe total number of pages
The API object used for modifying the PaginationState.
-
API
- .setCurrentPage(page)
- .setTotalPages(total)
Set the current page
Parameters
Name
Type
Description
page
NumberThe number to assign to the current page
Set the total number of pages
Parameters
Name
Type
Description
total
NumberThe number to set the amount of pages available
A React Hook that provides pagination logic.
Use this hook to implement components that need to navigate through paged data.
Returns: Array.<Object> — An array with two entries containing the following content: [PaginationState, API ]
Parameters
Name
Type
Default
Description
config
Object``
An object containing configuration values
config.namespace
String''The namespace to append to config.parameter in the query. For example: ?namespace_parameter=value
config.parameter
String'page'The name of the query parameter to use for page
config.initialPage
Number``
The initial current page value
config.initialTotalPages
Number1The total pages expected to be usable by this hook
Source Code: pwa-studio/packages/peregrine/lib/hooks/usePagination.js