score:3

after digging for three hours i found that you have to add the following prop to thetablepagination component as well as adding the ref as per other great answers explained (how to scroll to an element?):

selectprops(https://github.com/mui-org/material-ui/blob/f013f19bc2792a25663e8a3658aed0365c0a1964/packages/material-ui/src/tablepagination/tablepagination.js#l118) and i use scrollintoview instead of scrollto option.

so change your code to the following it should work:

  const tableref = react.useref(null)
...

<tablecontainer component={paper} ref={tableref}>
...

<tablepagination
  rowsperpageoptions={[5, 10, 25]}
            component="div"
            count={users.length}
            rowsperpage={rowsperpage}
            page={page}
            onchangepage={handlechangepage}
            onchangerowsperpage={handlechangerowsperpage}
            selectprops={{
          inputprops: { "aria-label": "rows per page" },
          native: true
        }}

          />
const handlechangerowsperpage = (event) => {
    tableref.current && tableref.current.scrollintoview();

    setrowsperpage(parseint(event.target.value, 10))
    setpage(0)
  }

Related Query

More Query from same tag