If you have any project questions, concerns, or contribution ideas, join our #pwa Slack channel. Find out how to create an account by visiting Community Resources

usePagination

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.

PaginationState

The current pagination state

Kind: global Object
Properties

Name Type Description
currentPage Number The current page number
totalPages Number The total number of pages

API

The API object used for modifying the PaginationState.

Kind: global Object

API.setCurrentPage(page)

Set the current page

Kind: static method of API

Param Type Description
page Number The number to assign to the current page

API.setTotalPages(total)

Set the total number of pages

Kind: static method of API

Param Type Description
total Number The number to set the amount of pages available

usePagination(config) ⇒ Array.<Object>

A React Hook that provides pagination logic.

Use this hook to implement components that need to navigate through paged data.

Kind: global function
Returns: Array.<Object> - An array with two entries containing the following content: [ PaginationState, API ]

Param 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.intialTotalPages Number 1 The total pages expected to be usable by this hook

For implementation details View Source.