title: React material-ui datagrid editing Issue
body: <p>I have created a Material UI DataGrid table and trying to make its fields editable. I am facing an issue while editing the fields using my custom logic. My custom editing logic works when I press enter however when I edit the value and then click outside of the column (somewhere else on the page) the internal value gets updated according to the logic however the displayed cell value doesn't match the updated value, it shows the user-edited value.</p>
  <pre><code>import React, { useEffect } from &quot;react&quot;;
  import { makeStyles, LinearProgress } from &quot;@material-ui/core&quot;;
  import {
    DataGrid,
    GridColDef,
    GridOverlay,
    GridCellEditCommitParams,
    GridValueFormatterParams,
  } from &quot;@material-ui/data-grid&quot;;    
  
  const useStyles = makeStyles({
    root: {
      &quot;&amp; .super-app-theme--header&quot;: {
        backgroundColor: &quot;#f2f2f2&quot;,
      },
    },
    muiGridRoot: {
      maxHeight: &quot;77px !important&quot;,
      &quot;&amp; .MuiDataGrid-columnHeaderTitle&quot;: {
        fontWeight: &quot;600 !important&quot; as any,
      },
    },
  });
  
  interface props {
    coilId: string;
  }
  
  export default function TargetMechnicalPropsTable({
    coilId,
  }: props) {
    const classes = useStyles();
    const [rows, setRows] = React.useState&lt;any&gt;([
      {
        id: 1,
        UpperLimitValue: 124.232,
        lowerLimitValue: 24.232,
        targetValue: 67.33,
        element: &quot;Yield Strength&quot;,
      },
    ]);
  
    const columns: GridColDef[] = [
      {
        field: &quot;id&quot;,
        hide: true,
        headerClassName: &quot;super-app-theme--header&quot;,
        sortable: false,
        flex: 1,
        align: &quot;center&quot;,
        headerAlign: &quot;center&quot;,
      },
      {
        field: &quot;element&quot;,
        headerName: &quot;Element&quot;,
        headerClassName: &quot;super-app-theme--header&quot;,
        editable: false,
        sortable: false,
        flex: 1,
        align: &quot;center&quot;,
        headerAlign: &quot;center&quot;,
      },
      {
        field: &quot;targetValue&quot;,
        headerName: &quot;Target value&quot;,
        headerClassName: &quot;super-app-theme--header&quot;,
        valueFormatter: (params: GridValueFormatterParams) =&gt; {
          const valueFormatted = Number(params.value as number).toFixed(4);
          return `${valueFormatted}`;
        },
        editable: true,
        //type: &quot;number&quot;,
        sortable: false,
        flex: 1,
        align: &quot;center&quot;,
        headerAlign: &quot;center&quot;,
      },
      {
        field: &quot;lowerLimitValue&quot;,
        headerName: &quot;Lower Limit&quot;,
        headerClassName: &quot;super-app-theme--header&quot;,
        valueFormatter: (params: GridValueFormatterParams) =&gt; {
          const valueFormatted = Number(params.value as number).toFixed(4);
          return `${valueFormatted}`;
        },
        editable: true,
        sortable: false,
        flex: 1,
        align: &quot;center&quot;,
        headerAlign: &quot;center&quot;,
      },
      {
        field: &quot;UpperLimitValue&quot;,
        headerName: &quot;Upper Limit&quot;,
        headerClassName: &quot;super-app-theme--header&quot;,
        sortable: false,
        valueFormatter: (params: GridValueFormatterParams) =&gt; {
          const valueFormatted = Number(params.value as number).toFixed(4);
          return `${valueFormatted}`;
        },
        editable: true,
        flex: 1,
        align: &quot;center&quot;,
        headerAlign: &quot;center&quot;,
      },
    ];
  
    const handleCellEditCommit = React.useCallback(
      ({ id, field, value }: GridCellEditCommitParams) =&gt; {
        const updatedRows = rows.map((row: any) =&gt; {
          if (row.id === id) {
            switch (field) {
              case &quot;lowerLimitValue&quot;:
                if (
                  Number(value) &lt; Number(row.targetValue) &amp;&amp;
                  Number(value) &lt; Number(row.UpperLimitValue)
                ) {
                  return { ...row, lowerLimitValue: Number(value) };
                } else {
                  return {
                    ...row,
                    lowerLimitValue: Number(row.lowerLimitValue),
                  };
                }
              case &quot;UpperLimitValue&quot;:
                if (
                  Number(value) &gt; Number(row.targetValue) &amp;&amp;
                  Number(value) &gt; Number(row.lowerLimitValue)
                ) {
                  return { ...row, UpperLimitValue: Number(value) };
                } else {
                  return {
                    ...row,
                    UpperLimitValue: Number(row.UpperLimitValue),
                  };
                }
              case &quot;targetValue&quot;:
                if (
                  Number(value) &gt; Number(row.lowerLimitValue) &amp;&amp;
                  Number(value) &lt; Number(row.UpperLimitValue)
                ) {
                  return { ...row, targetValue: Number(value) };
                } else {
                  return {
                    ...row,
                    targetValue: Number(row.targetValue),
                  };
                }
            }
          }
          return row;
        });
        setRows(updatedRows);
      },
      [rows]
    );
  
    return (
      &lt;div style={{ width: &quot;100%&quot; }} className={classes.root}&gt;
        &lt;DataGrid
          classes={{
            root: classes.muiGridRoot,
          }}
          rows={rows}
          columns={columns}
          hideFooterPagination
          hideFooter
          disableColumnMenu
          disableColumnFilter
          disableColumnSelector
          autoHeight
          disableExtendRowFullWidth
          density=&quot;compact&quot;
          onCellEditCommit={handleCellEditCommit}
        /&gt;
      &lt;/div&gt;
    );
  }
  </code></pre>
  <p>Please let me know what needs to be done for my custom logic to work when the user clicks outside of the column while editing it so that the user displayed value matches with the internal logic value.</p>
  <p>Thank you!</p>