Skip to content

Commit

Permalink
fix: usePrevNextPagination null safety
Browse files Browse the repository at this point in the history
Occasionally usePrevNextPagination would attempt a numeric operation on an undefined variable `currentPage`. This is now protected against.
  • Loading branch information
EthanFreestone committed Nov 16, 2023
1 parent 07d18db commit c2654b2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Change history for stripes-erm-components

## 9.1.0 In progress
* usePrevNextPagination null safety (yarn test warnings)

## 9.0.0 2023-10-12
* Added useParallelBatchFetch hook
Expand Down
2 changes: 1 addition & 1 deletion lib/hooks/usePrevNextPagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const usePrevNextPagination = ({
// Set up MCL specific props based on page
const pagingCanGoNext = currentPage && currentPage < Number(count) / pageSize;
const pagingCanGoPrevious = currentPage && Number(currentPage) > 1;
const pagingOffset = (currentPage - 1) * pageSize;
const pagingOffset = currentPage ? (currentPage - 1) * pageSize : 0;
const onNeedMoreData = (...args) => {
if (args[MCL_NEED_MORE_DATA_PREV_NEXT_ARG_INDEX]) {
handlePageChange(args[MCL_NEED_MORE_DATA_PREV_NEXT_ARG_INDEX]);
Expand Down

0 comments on commit c2654b2

Please sign in to comment.