MUI 数据网格渲染单元 getValue 返回未定义

问题描述

自从我在生产中推送我的代码后,我不能再在 renderCell 中调用 getValue

顺便说一下,环境和dev一样

这里是列定义:

const columns = [
        {
            field: 'edit',headerName: 'Edit',sortable: false,width: 78,renderCell: (params) => (
                <div>
                 <EditProduct defaultCats={props.defaultCats} prodId={params.getValue('id')} productIdGL={params.getValue('productId')} />
                </div>  
              ),align: "left",},{
            field: 'active',headerName: 'Off / On',width: 104,renderCell: (params) => (
                <div><CustomSwitch
                    checked={Boolean(params.value)}
                    onChange={() => myswitch(params.getValue('id'),Boolean(params.value))}
                    name="switch-"
                    inputProps={{ 'aria-label': 'primary checkBox' }}
                ></CustomSwitch>
                </div>  
              ),{ field: 'category_name',headerName: 'Catégorie',width: 120 },{ field: 'item_name',headerName: 'Nom du produit',width: 220 },{
          field: 'price',headerName: 'Prix de vente',type: 'number',width: 140,{
          field: 'profit',headerName: 'Profit par vente',width: 160,alt: 'Test'
        },{ field: 'type',headerName: 'Type',width: 90 },{ field: 'id',headerName: '#',width: 80 },];

错误

Unhandled Runtime Error
TypeError: Cannot read property 'undefined' of undefined

感谢任何帮助,因为此错误仅发生在生产中

多核:4.11.4 mui-datagrid: 4.0.0-alpha.26

解决方法

params.getValue(params.id,'id') || ''

代替

params.getValue('id')