diff --git a/.changeset/yellow-rules-eat.md b/.changeset/yellow-rules-eat.md new file mode 100644 index 00000000..7c88a3fd --- /dev/null +++ b/.changeset/yellow-rules-eat.md @@ -0,0 +1,5 @@ +--- +"@codedazur/react-pagination": patch +--- + +The computed page count is now calculated correctly when zero items are provided. diff --git a/packages/react-pagination/hooks/usePagination.ts b/packages/react-pagination/hooks/usePagination.ts index 99437322..2c06a8a1 100644 --- a/packages/react-pagination/hooks/usePagination.ts +++ b/packages/react-pagination/hooks/usePagination.ts @@ -89,7 +89,7 @@ export function usePagination( ); const clampIndex = useCallback( - (index: number) => clamp(index, 1, computedPages), + (index: number) => clamp(index, 1, Math.max(1, computedPages)), [computedPages], );