How can I change rowsPerPage in MaterialReactTable?

70 views Asked by At

I used MaterialReactTable and I want to show just 5 items in each pagination. I set muiTablePaginationProps but I still have 10 items.How can I do?

 <MaterialReactTable
  columns={columns}
  data={data.data}
  muiTablePaginationProps={{
    rowsPerPageOptions: [5],
    rowsPerPage: 5,
  }}

/>
1

There are 1 answers

1
PooriaSetayesh On BEST ANSWER

Based on material-react-table documentation (Pagination Feature Guide) you should remove rowsPerPage from muiTablePaginationProps and add initialState property to MaterialReactTable component as follows:

<MaterialReactTable
  initialState={{ pagination: { pageSize: 5,pageIndex: 0 } }}
  columns={columns}
  data={data}
  muiTablePaginationProps={{
    rowsPerPageOptions: [5],
  }}
/>;

You can see image preview at here