-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DataGrid] Setting page with ApiRef in useEffect does not work anymore #1815
Comments
@dtassone When you open an issue, please always follow the issue template. For instance, we miss a codesandbox and the version. |
Regarding the change of behavior, it originates from #1583 (not from the refactoring part, but from the fix of #1517). I should have made it more obvious by commenting on it. I thought that the tradeoff was negligible so I didn't mention it. As a side note. I should have moved the refactoring to a different PR, this is a great example of what I did sucks. |
The If I add a check on the rows length in the React.useEffect(() => {
if (data.rows.length) {
apiRef.current.setPage(1);
}
}, [data, apiRef]); But, it's still to soon because it occurs before the For me the real issue here is that we have async cascade state update, so the We should trigger the By the way, these async state update create weird intermediate states. Here is the detailed order :
Without my fix in the story, the call to With my fix in the story, ( |
Relates to #2044 (check after refactoring the pagination with the new controlled state pattern) |
I confirm that #2099 fixes this one. proof: https://deploy-preview-2099--material-ui-x.netlify.app/storybook/?path=/story/x-grid-tests-pagination--page-2-api&globals=measureEnabled:false |
Broken story
https://material-ui-x.netlify.app/storybook/?path=/story/x-grid-tests-pagination--page-2-api
Expected to render rows 51-100 of 2000
Instead it renders rows 1-50 of 2000
TODO add as snap test
The text was updated successfully, but these errors were encountered: