diff --git a/packages/x-data-grid/src/hooks/features/rowSelection/useGridRowSelection.ts b/packages/x-data-grid/src/hooks/features/rowSelection/useGridRowSelection.ts index fcbdab88a2d9..9d5b7f8e0aa3 100644 --- a/packages/x-data-grid/src/hooks/features/rowSelection/useGridRowSelection.ts +++ b/packages/x-data-grid/src/hooks/features/rowSelection/useGridRowSelection.ts @@ -446,7 +446,6 @@ export const useGridRowSelection = ( const removeOutdatedSelection = React.useCallback( (sortModelUpdated = false) => { if (isFirstRender.current) { - isFirstRender.current = false; return; } const currentSelection = gridRowSelectionStateSelector(apiRef.current.state); @@ -762,4 +761,10 @@ export const useGridRowSelection = ( React.useEffect(() => { runIfRowSelectionIsEnabled(removeOutdatedSelection); }, [removeOutdatedSelection, runIfRowSelectionIsEnabled]); + + React.useEffect(() => { + if (isFirstRender.current) { + isFirstRender.current = false; + } + }, []); };