Skip to content

Commit

Permalink
fix(react-pagination): correct computed page count
Browse files Browse the repository at this point in the history
  • Loading branch information
thijsdaniels committed Jun 4, 2024
1 parent e5dcf68 commit e6e17d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/yellow-rules-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@codedazur/react-pagination": patch
---

The computed page count is now calculated correctly when zero items are provided.
2 changes: 1 addition & 1 deletion packages/react-pagination/hooks/usePagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function usePagination<T>(
);

const clampIndex = useCallback(
(index: number) => clamp(index, 1, computedPages),
(index: number) => clamp(index, 1, Math.max(1, computedPages)),
[computedPages],
);

Expand Down

0 comments on commit e6e17d3

Please sign in to comment.