Skip to content

Commit 7683de0

Browse files
committed
on page change or rows per page change
1 parent c9d87bc commit 7683de0

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/components/TablePagination.tsx

+6-8
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,7 @@ export type TablePaginationProps<
2424
AdditionalProps = {},
2525
> = Omit<
2626
MuiTablePaginationProps<RootComponent, AdditionalProps>,
27-
| "component"
28-
| "count"
29-
| "rowsPerPage"
30-
| "onRowsPerPageChange"
31-
| "page"
32-
| "onPageChange"
33-
| "rowsPerPageOptions"
27+
"component" | "count" | "rowsPerPage" | "page" | "rowsPerPageOptions"
3428
> & {
3529
children: (
3630
data: ResultType["data"],
@@ -60,6 +54,8 @@ const TablePagination = <
6054
rowsPerPage: initialLimit = 50,
6155
rowsPerPageOptions = [50, 100, 150],
6256
stackProps,
57+
onRowsPerPageChange,
58+
onPageChange,
6359
...tablePaginationProps
6460
}: TablePaginationProps<
6561
QueryArg,
@@ -106,10 +102,12 @@ const TablePagination = <
106102
rowsPerPage={limit}
107103
onRowsPerPageChange={event => {
108104
setPagination({ limit: parseInt(event.target.value), page: 0 })
105+
if (onRowsPerPageChange) onRowsPerPageChange(event)
109106
}}
110107
page={page}
111-
onPageChange={(_, page) => {
108+
onPageChange={(event, page) => {
112109
setPagination(({ limit }) => ({ limit, page }))
110+
if (onPageChange) onPageChange(event, page)
113111
}}
114112
// ascending order
115113
rowsPerPageOptions={rowsPerPageOptions.sort((a, b) => a - b)}

0 commit comments

Comments
 (0)