-
-
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
[DataGridPro] Fetch new rows only once when multiple models are changed in one cycle (@arminmeh) #16382
Conversation
Deploy preview: https://deploy-preview-16382--material-ui-x.netlify.app/ |
Are you sure these tests function properly? For whatever reason, Edited Moved beforeEach(() => {
console.log('RESET');
fetchRowsSpy.resetHistory();
}); Added a console.log to const dataSource: GridDataSource = React.useMemo(() => {
console.log('useMemo');
// [redacted]
}, []);
```
Tests start failing:
```
Chrome Headless 133.0.0.0 (Mac OS 10.15.7) WARN: 'including inaccessible elements by default'
LOG: 'RESET'
LOG: 'useMemo'
LOG: 'useMemo'
.
LOG: 'RESET'
LOG: 'useMemo'
LOG: 'useMemo'
.
LOG: 'RESET'
LOG: 'useMemo'
LOG: 'useMemo'
.
LOG: 'RESET'
LOG: 'useMemo'
LOG: 'useMemo'
.
LOG: 'RESET'
LOG: 'useMemo'
LOG: 'useMemo'
Chrome Headless 133.0.0.0 (Mac OS 10.15.7) <DataGridPro /> - Data source tree data should fetch nested data when clicking on a dropdown FAILED
AssertionError: expected 1 to equal 11
LOG: 'RESET'
LOG: 'useMemo'
LOG: 'useMemo'
Chrome Headless 133.0.0.0 (Mac OS 10.15.7) <DataGridPro /> - Data source tree data should fetch nested data when calling API method `unstable_dataSource.fetchRows` FAILED
AssertionError: expected 1 to equal 11
LOG: 'RESET'
LOG: 'useMemo'
LOG: 'useMemo'
Chrome Headless 133.0.0.0 (Mac OS 10.15.7) <DataGridPro /> - Data source tree data should lazily fetch nested data when using `defaultGroupingExpansionDepth` FAILED
AssertionError: expected +0 to be above +0
``` |
When I add the dep back into LOG: 'RESET'
LOG: 'useMemo'
LOG: 'useMemo'
.
LOG: 'RESET'
LOG: 'useMemo'
LOG: 'useMemo'
.
LOG: 'RESET'
LOG: 'useMemo'
LOG: 'useMemo'
.
LOG: 'RESET'
LOG: 'useMemo'
LOG: 'useMemo'
.
LOG: 'RESET'
LOG: 'useMemo'
LOG: 'useMemo'
LOG: 'useMemo'
LOG: 'useMemo'
Chrome Headless 133.0.0.0 (Mac OS 10.15.7) <DataGridPro /> - Data source tree data should fetch nested data when clicking on a dropdown FAILED
AssertionError: expected 3 to equal 2
LOG: 'RESET'
LOG: 'useMemo'
LOG: 'useMemo'
LOG: 'useMemo'
LOG: 'useMemo'
Chrome Headless 133.0.0.0 (Mac OS 10.15.7) <DataGridPro /> - Data source tree data should fetch nested data when calling API method `unstable_dataSource.fetchRows` FAILED
AssertionError: expected 2 to equal 1
LOG: 'RESET'
LOG: 'useMemo'
LOG: 'useMemo'
LOG: 'useMemo'
LOG: 'useMemo'
Chrome Headless 133.0.0.0 (Mac OS 10.15.7) <DataGridPro /> - Data source tree data should lazily fetch nested data when using `defaultGroupingExpansionDepth` FAILED
AssertionError: expected 2 to equal 1 |
Modified Have many failing tests around datasource now (17 browser tests I think), all of them share the same flaw – I wonder if the datasource prop is something that should be aggressively memoized by default by the Datagrid (if the creators are struggling, think about the average developer 🙈) – feels like too easy to make mistakes, and something that ought not to actually need to change during rendering. |
This only occurs because of unstable
Yes, this is the exact problem. I have basically worked around it. Data is created after the initial render. This makes Once the You can add this after the response
and add verbose output in the
that will log exactly one request (with tests expecting one request) even though I have noticed that some test are passing prematurely because they wait for one request which is an empty response and the second (real one) comes after that. If you have time to fix this, so that we have stable
This will cause the mock server to always return an empty response. |
Better yet would be to use a non-hook version of |
Cherry-pick of #16101 and #16395