Skip to content

Commit

Permalink
Merge pull request #110 from astahmer/fix/page-size-default
Browse files Browse the repository at this point in the history
fix: pageSize should default to pageSizes[0]
  • Loading branch information
Kuechlin authored Oct 28, 2022
2 parents a2a8743 + 1779c91 commit 1ac4ac1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/DataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,14 @@ export function DataGrid<TData extends RowData>({
onRowSelectionChange: handleRowSelectionChange,
}));

const defaultPageSize = Number(pageSizes?.[0] ?? DEFAULT_INITIAL_SIZE);
useEffect(() => {
if (withPagination) {
table.setPageSize(initialState?.pagination?.pageSize ?? DEFAULT_INITIAL_SIZE);
table.setPageSize(initialState?.pagination?.pageSize ?? defaultPageSize);
} else {
table.setPageSize(data.length);
}
}, [table, withPagination, data.length, initialState?.pagination?.pageSize]);
}, [table, withPagination, data.length, initialState?.pagination?.pageSize, defaultPageSize]);

return (
<Stack {...others} spacing={verticalSpacing} className={classes.wrapper}>
Expand Down

0 comments on commit 1ac4ac1

Please sign in to comment.