Skip to content

Commit

Permalink
[DataGridPro] Fix row pre-processing running with a stale data source (
Browse files Browse the repository at this point in the history
  • Loading branch information
MBilalShafi authored Oct 3, 2024
1 parent 7923dd1 commit c39b734
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/x-data-grid/src/hooks/features/rows/useGridRows.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import useLazyRef from '@mui/utils/useLazyRef';
import { GridEventListener } from '../../../models/events';
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
Expand Down Expand Up @@ -73,6 +74,7 @@ export const useGridRows = (
| 'pagination'
| 'paginationMode'
| 'loading'
| 'unstable_dataSource'
>,
): void => {
if (process.env.NODE_ENV !== 'production') {
Expand Down Expand Up @@ -536,15 +538,20 @@ export const useGridRows = (
throttledRowsChange,
]);

const previousDataSource = useLazyRef(() => props.unstable_dataSource);
const handleStrategyProcessorChange = React.useCallback<
GridEventListener<'activeStrategyProcessorChange'>
>(
(methodName) => {
if (props.unstable_dataSource && props.unstable_dataSource !== previousDataSource.current) {
previousDataSource.current = props.unstable_dataSource;
return;
}
if (methodName === 'rowTreeCreation') {
groupRows();
}
},
[groupRows],
[groupRows, previousDataSource, props.unstable_dataSource],
);

const handleStrategyActivityChange = React.useCallback<
Expand Down

0 comments on commit c39b734

Please sign in to comment.