New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[material-ui][TablePagination] Out of range error #40234
Comments
Adding this piece of code in the TablePagination component fixes this issue: React.useEffect(() => {
const newLastPage = Math.max(0, Math.ceil(count / rowsPerPage) - 1);
if (page > newLastPage) {
onPageChange(null, newLastPage);
}
}, [count, page, rowsPerPage, onPageChange]); However should this fix be implemented in the component itself? If so, I can open a pull request for this fix - however in my honest opinion it would pollute the component itself. What do you guys think? |
Thanks for your reply, I've tried this in the sandbox : https://codesandbox.io/p/sandbox/zealous-perlman-forked-9kskcl |
You mean in the node_module folder ??? There isn't another solution ? |
No no, I mean I meant to add this code in the core package so it gets fixed for you, but that was more of a question to the maintainers haha, sorry for the confusion. |
You should address this in your component, which is why we issue the warning. Previously, we handled it in the Table Pagination component, but we removed that functionality in #14534. You can find the reasoning behind this decision in the discussion in #13995. Furthermore, I don't believe you need to use Check out the updated CodeSandbox: here. |
Duplicates
Latest version
Steps to reproduce 馃暪
Link to live example: https://codesandbox.io/p/sandbox/zealous-perlman-forked-yyqttv
Steps:
Current behavior 馃槸
No response
Expected behavior 馃
no error
Context 馃敠
When I remove an item in a page, and this is the last (like 11th element), I want to go to previous page.
But, there is an error because on page 1, there isn't no more items.
Your environment 馃寧
No response
The text was updated successfully, but these errors were encountered: