Skip to content

Need alternative to removed onTableInstanceChange prop #526

Answered by skempisty
skempisty asked this question in Q&A
Discussion options

You must be logged in to vote

I found a way to get what I need. Github won't let me simply delete this discussion so I'll share what I did.

I used an 'external' pagination state like

const [pagination, setPagination] = useState({
  pageIndex: 0,
  pageSize: 10,
});

attached it to my MaterialReactTable like

<MaterialReactTable
  data={accessList ?? []}
  columns={columns}
  overrideState={{
    pagination,
  }}
  onPaginationChange={setPagination}
/>

and listen to the pagination value changes with useEffect

useEffect(() => {
  const updatedShownRowCount = tableRef?.current?.getPaginationRowModel()?.rows?.length ?? 0;
  const updatedTotalRowCount = tableRef?.current?.getFilteredRowModel()?.rows?.length ?? 0;
  
  setS…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@KevinVandy
Comment options

Answer selected by skempisty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants