I'm facing an issue regarding page changing while the length of array is changed. I'm mapping an array and showing 8 items per page, when I go into page 2 and delete 7 items it work fine and stay in page 2 but the issue occurs when i delete the 8th item, the props.images(array) changes, the pagecount also change from 2 -> 1 but pageNumber does remain same(1) not 0. I want to update the pageNumber when the length of data is change. Any sort of tips will help me to resolve this bug, Thank you.
Issue/Bug/Scenario
I'm facing an issue regarding page changing while the length of array is changed. I'm mapping an array and showing 8 items per page, when I go into page 2 and delete 7 items it work fine and stay in page 2 but the issue occurs when i delete the 8th item, the props.images(array) changes, the pagecount also change from 2 -> 1 but pageNumber does remain same(1) not 0. I want to update the pageNumber when the length of data is change. Any sort of tips will help me to resolve this bug, Thank you.
Code