1 parent da851ce commit 6aa9e14Copy full SHA for 6aa9e14
1 file changed
src/pages/me/polls/index.tsx
@@ -44,7 +44,7 @@ const MyPolls: NextPage = () => {
44
POLLS_PER_PAGE * page,
45
POLLS_PER_PAGE * page + POLLS_PER_PAGE
46
);
47
- const canGoNext = page < Math.floor(polls.length / POLLS_PER_PAGE);
+ const canGoNext = page + 1 < polls.length / POLLS_PER_PAGE;
48
const canGoBack = page > 0;
49
const hasPolls = paginatedPolls.length > 0;
50
@@ -91,6 +91,13 @@ const MyPolls: NextPage = () => {
91
}
92
};
93
94
+ useEffect(() => {
95
+ const pagesOverflow = page * POLLS_PER_PAGE >= polls.length;
96
+ if (pagesOverflow && !isLoading) {
97
+ setPage((prev) => prev - 1);
98
+ }
99
+ }, [polls, page, isLoading]);
100
+
101
useEffect(() => {
102
if (id) {
103
loadPolls();
0 commit comments