Skip to content

Commit

Permalink
[DataGrid] Fix rows not being recomputed on props.rowCount change (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
MBilalShafi authored May 2, 2024
1 parent 0a88646 commit bb57c87
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/x-data-grid/src/hooks/features/rows/useGridRows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export const useGridRows = (
const currentPage = useGridVisibleRows(apiRef, props);

const lastUpdateMs = React.useRef(Date.now());
const lastRowCount = React.useRef(props.rowCount);
const timeout = useTimeout();

const getRow = React.useCallback<GridRowApi['getRow']>(
Expand Down Expand Up @@ -594,6 +595,12 @@ export const useGridRows = (
return;
}

let isRowCountPropUpdated = false;
if (props.rowCount !== lastRowCount.current) {
isRowCountPropUpdated = true;
lastRowCount.current = props.rowCount;
}

const areNewRowsAlreadyInState =
apiRef.current.caches.rows.rowsBeforePartialUpdates === props.rows;
const isNewLoadingAlreadyInState =
Expand Down Expand Up @@ -625,8 +632,9 @@ export const useGridRows = (
apiRef.current.caches.rows.rowCountPropBeforePartialUpdates = props.rowCount;
apiRef.current.forceUpdate();
}

return;
if (!isRowCountPropUpdated) {
return;
}
}

logger.debug(`Updating all rows, new length ${props.rows.length}`);
Expand Down

0 comments on commit bb57c87

Please sign in to comment.