mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-08-24 03:55:49 -05:00
Fix it being possible to get empty paginated list
This commit is contained in:
@@ -32,6 +32,12 @@ export function useSimplePagination<T>({
|
||||
const thereIsNextPage = currentPage < pagesCount;
|
||||
const thereIsPreviousPage = currentPage > 1;
|
||||
|
||||
// if the list changes from externally it might be that we are on a page that doesn't exist anymore
|
||||
// setting state inside render looks weird but should be ok
|
||||
if (itemsToDisplay.length === 0 && currentPage > 1) {
|
||||
setCurrentPage(1);
|
||||
}
|
||||
|
||||
return {
|
||||
pagesCount,
|
||||
currentPage,
|
||||
|
||||
Reference in New Issue
Block a user