mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-08-07 21:56:33 -05:00
Fix it being possible to get empty paginated list
This commit is contained in:
parent
e1b18d710a
commit
dad6c8ea2c
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user