Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 如何对条件over-map函数进行反应_Reactjs - Fatal编程技术网

Reactjs 如何对条件over-map函数进行反应

Reactjs 如何对条件over-map函数进行反应,reactjs,Reactjs,我试图用条件语句循环一些数据,但是我的条件语句出现了解析错误 const unitTests = unitTestTemplates.map((item) => if (item.typical_dq_domain){ console.log('hello') } ) map回调需要一个函数体,即.map(item=>{…}),如果它不是隐式返回值的话

我试图用条件语句循环一些数据,但是我的条件语句出现了解析错误

 const unitTests = unitTestTemplates.map((item) => 
  
  if (item.typical_dq_domain){
    console.log('hello')
  }
  
  )

map回调需要一个函数体,即
.map(item=>{…})
,如果它不是隐式返回值的话<如果(…)不是有效的返回值,则需要函数体

const unitTests = unitTestTemplates.map((item) => {
  if (item.typical_dq_domain) {
    console.log('hello')
  }

  ...
  // return some value for mapping
})