How to insert a console.log in material-ui elements to verify object/array/value

孤街浪徒 提交于 2020-07-10 08:12:03

问题


I am getting an error from react js when I execute this code snippet:

<TableBody>
  { (data.length > 0) ? (
    data.map((x, i) => row(
    x,
    i,
    formColumns,
    handleRemove,
    handleSelect,
    editIdx
    ))) : (<TableRow><TableCell colSpan={`${cols}`}>No Data</TableCell></TableRow>)}
</TableBody>

The value of 'data' is an empty array [], which SHOULD return a length of 0 But it passes the length test somehow.

Instead I get an error 'data.map is not a function'.

I am trying to insert:

console.log('data = ' + JSON.Stringify(data, null, 2) + '.'))

in the code somewhere, so I can see what it's doing. When I check the data GOING IN to the Table, it's = []. So why is the length not working, and what do I need to do to place javascript code inside a set of material-ui elements? Any help would be much appreciated!


回答1:


Something like:

{ console.log('data = ' + JSON.Stringify(data, null, 2) + '.')) }



来源:https://stackoverflow.com/questions/62751068/how-to-insert-a-console-log-in-material-ui-elements-to-verify-object-array-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!