简体   繁体   English

react 中的材料表不显示 onRowAdd 中的数据,但 state 已更改

[英]material-table in react does not display data in onRowAdd but but the state is changed

This is my onRowAdd function, before adding the value in the table I'm testing if the values provided are true or not.这是我的 onRowAdd function,在添加表中的值之前,我正在测试提供的值是否为真。

The Issue is that when input values are true, new data newData is added into the state, but the material table does not display them.问题是当输入值为真时,新数据 newData 被添加到 state 中,但材料表不显示它们。 It's added but not visible已添加但不可见

Then when I clicked on the edit icon it shows me the values that were entered before but after saving it still, the values vanish.然后,当我单击编辑图标时,它会显示之前输入的值,但在保存之后,这些值就消失了。 As shown in the image new row was added and action are also shown in it but material table is not displaying the values of the column.如图所示,添加了新行,其中也显示了操作,但材料表未显示该列的值。

'onRowAdd: newData =>'
    new Promise((resolve, reject) => {
        setTimeout(() => {
            handleTestConnection(newData)
            .then(isValid => {
                if (isValid) {
                    setData([...data, newData])
                    resolve();
                } else reject();
                    })
                }, 1000)
        })    

在此处输入图像描述

The problem was that there is a render property in material-table and I was passing an empty function to it why material-table was adding the values but was not displaying them.问题是材料表中有一个渲染属性,我将一个空的 function 传递给它,为什么材料表正在添加值但没有显示它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM