diff --git a/packages/ra-ui-materialui/src/list/datagrid/DatagridRow.tsx b/packages/ra-ui-materialui/src/list/datagrid/DatagridRow.tsx index 80d4f8a15e1..d1a7b9011d8 100644 --- a/packages/ra-ui-materialui/src/list/datagrid/DatagridRow.tsx +++ b/packages/ra-ui-materialui/src/list/datagrid/DatagridRow.tsx @@ -69,7 +69,7 @@ const DatagridRow: FC = React.forwardRef((props, ref) => { expand; const resource = useResourceContext(props); const [expanded, toggleExpanded] = useExpanded(resource, id); - const [nbColumns, setNbColumns] = useState( + const [nbColumns, setNbColumns] = useState(() => computeNbColumns(expandable, children, hasBulkActions) ); useEffect(() => {