Reputation: 21
the default page index seems to be '0' in material table , but the api im working with starts off from page index '1' , how can i change the default page index of the table to as that of API
Upvotes: 2
Views: 2485
Reputation: 1167
***The Best way is***
import { TablePagination} from "@material-ui/core";
const [page, setPage] = React.useState(1);
<TablePagination page={page - 1} onChangePage={handleChangePage} />
const handleChangePage = (event, newPage) => {
setPage(newPage + 1);
};
Upvotes: 1