[英]this.props working in console.log of child component, but not rendering
[英]React not rendering props but can see in console.log
在我的渲染中,我有这个const arr = []
作为回报,我有这个
{
this.state.rows.map((qc) =>
qc.BinsByDayByOrchardsQCs.map((qc2) =>
qc2.BinsByDayByOrchardsQCsDefects.map((qc3) =>
{!arr.includes(qc3.Defect) && arr.push(qc3.Defect) &&
(<div className="row table">
<div className="column-label bold">{qc3.Defect}</div>
{console.log("testing", qc3.Defect)}
</div>)
}
)
)
)
}
在console.log中,我实际上可以看到4个结果,这是我想要的结果。 看起来像这样:
testing Scuff
testing Sunburn
testing Bruise
testing Hail damage
关于为什么页面上什么都没有呈现的任何想法?
因为您有花括号{}
,所以需要将其更改为括号()
或使用显式的return
语句:
qc2.BinsByDayByOrchardsQCsDefects.map((qc3) =>
{!arr.includes(qc3.Defect) && arr.push(qc3.Defect) &&
(<div className="row table">
<div className="column-label bold">{qc3.Defect}</div>
{console.log("testing", qc3.Defect)}
</div>)
)
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.