Skip to content

Commit 7d0ac56

Browse files
BesOlivierBouchardgithub-actions[bot]SamuelT-Beslogic
authored
#365 Fix current page of the infinite scroll hook (#366)
--------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Samuel T. <samuel.therrien@beslogic.com>
1 parent aa8a60a commit 7d0ac56

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

canopeum_frontend/src/hooks/PostsInfiniteScrollingHook.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ const usePostsInfiniteScrolling = () => {
4646
morePostsLoaded(response.results)
4747
}
4848

49-
setCurrentPage(previous => previous + 1)
49+
// FIXME: There's currently an issue where this is triggered multiple times
50+
// and sending multiple requests.
51+
// If we "correctly" re-use the previous state using `previous => previous + 1`,
52+
// this number will rapidly increase past the intended pagination.
53+
setCurrentPage(currentPage + 1)
5054
setLoadingError(undefined)
5155
} catch (error: unknown) {
5256
setLoadingError(getErrorMessage(error, translate('posts.error-loading-posts')))

0 commit comments

Comments
 (0)