mirror of
https://github.com/gosticks/react-table.git
synced 2025-10-16 11:55:36 +00:00
fix: manualPagination does not work with pageCount -1 (#2024)
* fix: manualPagination does not work with pageCount -1 * fix: manualPagination does not work with pageCount -1
This commit is contained in:
parent
0f695e7321
commit
e73199a04d
@ -43,12 +43,18 @@ function reducer(state, action, previousState, instance) {
|
||||
}
|
||||
|
||||
if (action.type === actions.gotoPage) {
|
||||
const { pageCount } = instance
|
||||
const { pageCount, page, rows } = instance
|
||||
const newPageIndex = functionalUpdate(action.pageIndex, state.pageIndex)
|
||||
const cannnotPreviousPage = newPageIndex < 0
|
||||
const cannotNextPage =
|
||||
pageCount === -1
|
||||
? page.length < state.pageSize
|
||||
: newPageIndex > pageCount - 1
|
||||
|
||||
if (newPageIndex < 0 || newPageIndex > pageCount - 1) {
|
||||
if (cannnotPreviousPage || cannotNextPage) {
|
||||
return state
|
||||
}
|
||||
|
||||
return {
|
||||
...state,
|
||||
pageIndex: newPageIndex,
|
||||
@ -153,7 +159,8 @@ function useInstance(instance) {
|
||||
])
|
||||
|
||||
const canPreviousPage = pageIndex > 0
|
||||
const canNextPage = pageCount === -1 || pageIndex < pageCount - 1
|
||||
const canNextPage =
|
||||
pageCount === -1 ? page.length >= pageSize : pageIndex < pageCount - 1
|
||||
|
||||
const gotoPage = React.useCallback(
|
||||
pageIndex => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user