[英]React not rendering props but can see in console.log
in my render, I have this const arr = []
在我的渲染中,我有这个
const arr = []
In my return I have this 作为回报,我有这个
{
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>)
}
)
)
)
}
In my console.log I can actually see the 4 results, which is my desired outcome. 在console.log中,我实际上可以看到4个结果,这是我想要的结果。 It looks like this:
看起来像这样:
testing Scuff
testing Sunburn
testing Bruise
testing Hail damage
Any ideas on why nothing is rendering on the page? 关于为什么页面上什么都没有呈现的任何想法?
Because you have curly braces {}
, you need to either change them to parentheses ()
or use an explicit return
statement: 因为您有花括号
{}
,所以需要将其更改为括号()
或使用显式的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.