Skip to content

Commit

Permalink
Update dependency array on setPage
Browse files Browse the repository at this point in the history
This fixes an issue where search parameters were not updated correctly when changing pages in the pagination component. The root cause was the missing onChange dependency in the setPage callback function, which prevented the correct state from being passed on page changes.

Changes:
Add the onChange function to the dependency array of the setPage callback to ensure it always reflects the latest state.

Impact:
This fix ensures that the pagination component accurately reflects the current state when triggering onChange.
  • Loading branch information
jesuzon committed May 4, 2024
1 parent f28b1e9 commit d17a98d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/hooks/use-pagination/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function usePagination(props: UsePaginationProps) {
onChangeActivePage(pageNumber);
}
},
[total, activePage],
[total, activePage, onChange],
);

const next = () => (isRTL ? setPage(activePage - 1) : setPage(activePage + 1));
Expand Down

0 comments on commit d17a98d

Please sign in to comment.