# Vidly app pagination bug

**URL:** <https://forum.codewithmosh.com/t/vidly-app-pagination-bug/16014>\
**Category:** React\
**Created:** [October 23, 2022, 2:52pm UTC](https://forum.codewithmosh.com/t/vidly-app-pagination-bug/16014 "2022-10-23T14:52:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dumbfounded](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@Dumbfounded](https://forum.codewithmosh.com/u/Dumbfounded)\
**Post date:** [October 23, 2022, 2:52pm UTC](https://forum.codewithmosh.com/t/vidly-app-pagination-bug/16014/1 "2022-10-23T14:52:40Z")

</div>

Hi there,if I have 3 pages with 4-4-1 movies and if I go to third page and delete that single movie it won’t change to second page and if I delete all 4 movies on second page all movies disappear.  
Did anyone notice this and fixed it?

---

<div class="post-metadata">

**Author:** ![onlyhasbi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/onlyhasbi/32/4608_2.png) [@onlyhasbi](https://forum.codewithmosh.com/u/onlyhasbi)\
**Post date:** [October 24, 2022, 9:45pm UTC](https://forum.codewithmosh.com/t/vidly-app-pagination-bug/16014/2 "2022-10-24T21:45:12Z")

</div>

```auto
useEffect(() => {
   const pagesCount = Math.ceil(totalMovies / pageSize);
    if (currentPage > pagesCount) setCurrentPage(pagesCount);
 }, [currentPage, totalMovies, pagesCount]);

```

try add this in your code
