Skip to content

Commit d7a35e0

Browse files
committed
add canFirstPage and canLastPage
1 parent e838568 commit d7a35e0

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ export function usePaginate<T>(items: T[], options: UsePaginateOptions = {}) {
6060
const lastPageIndex = safeIndex(pageCount - 1);
6161
const nextPageIndex = safeIndex(pageIndex + 1);
6262
const prevPageIndex = safeIndex(pageIndex - 1);
63+
const canFirstPage = pageIndex !== 0;
64+
const canLastPage = pageIndex !== lastPageIndex;
6365
const canNextPage = pageIndex < lastPageIndex;
6466
const canPrevPage = pageIndex > 0;
65-
const canFirstPage = pageIndex > 0;
66-
const canLastPage = pageIndex > 0;
6767

6868
useEffect(() => {
6969
if (pageIndex > lastPageIndex) {
@@ -109,6 +109,8 @@ export function usePaginate<T>(items: T[], options: UsePaginateOptions = {}) {
109109
}
110110

111111
return {
112+
canFirstPage,
113+
canLastPage,
112114
canNextPage,
113115
canPrevPage,
114116
changePage: handleChangePage,

0 commit comments

Comments
 (0)