
usePaginationusePagination is the hook that implements row pagination. It can be used for both client-side pagination or server-side pagination. For more information on pagination, see Pagination
NOTE Some server-side pagination implementations do not use page index and instead use token based pagination! If that's the case, please use the
useTokenPaginationplugin instead.
The following options are supported via the main options object passed to useTable(options)
initialState.pageSize: Int10initialState.pageIndex: Int0page instance valuepageCount: IntmanualPagination is set to truemanualPagination is true, then this value used to determine the amount of pages available. This amount is then used to materialize the pageOptions and also compute the canNextPage values on the table instance.-1 if you don't know or don't want to present the number of pages available. canNextPage will return false if page data length is less than pageSize, otherwise true.manualPagination: BoolautoResetPage: Booleantruetrue, the pageIndex state will automatically reset if manualPagination is false and any of the following conditions are met:data is changedmanualSortBy is false and state.sortBy is changedmanualGlobalFilter is false and state.globalFilter is changedmanualFilters is false and state.filters is changedmanualGroupBy is false and state.groupBy is changedfalsepaginateExpandedRows: BooluseExpanded plugin hook simultaneouslytruetrue, expanded rows are paginated along with normal rows. This results in stable page sizes across every page.false, expanded rows will be spliced in after pagination. This means that the total number of rows in a page can potentially be larger than the page size, depending on how many subrows are expanded.The following values are provided to the table instance:
state.pageIndex: IntpageIndex value, located on the state.state.pageSize: IntpageSize value, located on the state.page: Array<row>pageIndex value.pageCount: IntmanualPagination is set to false, this is the total amount of pages available in the table based on the current pageSize valuemanualPagination is set to true, this is merely the same pageCount option that was passed in the table options.pageOptions: Array<Int>canPreviousPage: BoolpageIndex is greater than 0, this will be truecanNextPage:pageIndex is less than pageCount, this will be truegotoPage: Function(pageIndex)pageIndex, will set pageIndex to that value.pageIndex range, then this function will do nothing.previousPage: Functionstate.pageIndex by one.canPreviousPage is false, this function will do nothing.nextPage: Functionstate.pageIndex by one.canNextPage is false, this function will do nothing.setPageSize: Function(pageSize)state.pageSize to the new value.state.pageIndex is also calculated. It is calculated via Math.floor(currentTopRowIndex / newPageSize)The best JavaScript newsletter! Delivered every Monday to over 76,000 devs.