Skip to content

Commit c6f04a8

Browse files
committed
table pagination fix: when first loaded the data, there is only show 1 page number, but there are many pages
1 parent 22cc6cd commit c6f04a8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/apps/admin/src/lib/components/common/Pagination/Pagination.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ const Pagination: FC<PaginationProps> = (props: PaginationProps) => {
5252
const pages = []
5353
for (
5454
let i = props.page - MAX_PAGE_DISPLAY + 1;
55-
i <= props.page;
55+
i <= props.page + MAX_PAGE_DISPLAY;
5656
i++
5757
) {
58-
if (i >= 1) {
58+
if (i >= 1 && i <= props.totalPages && pages.length < MAX_PAGE_DISPLAY) {
5959
pages.push(i)
6060
}
6161
}
@@ -95,7 +95,7 @@ const Pagination: FC<PaginationProps> = (props: PaginationProps) => {
9595

9696
return [...oldDisplayPages]
9797
})
98-
}, [props.page])
98+
}, [props.page, props.totalPages])
9999

100100
useEffect(() => {
101101
createDisplayPages()

0 commit comments

Comments
 (0)