javascript - React 不渲染道具,但可以在 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>)
)
)
推荐阅读
- javascript - 如何获取标签内容的链接?
- html - 使用 CSS 设置具有相同类名的独立 div 的相同高度
- shell - 带有 sed 抛出 *** 目标模式的 Makefile 不包含“%”。停止
- c# - 我可以在 C# 中分析在外部 dll 中分配的内存吗(例如使用 Visual Studio)
- xamarin.forms - 数字滚动动画
- c# - 如何使用 C# 在 IIS Express 中创建虚拟目录
- google-apps-script - 谷歌表格 - 如果勾选一个框,创建一个带有按钮的弹出消息
- python - 如何恢复实例以使用类属性而不是阴影实例属性?
- scala - DataSet/DataStream 类型类接口
- javascript - 有没有直接区分键盘键的方法?像钥匙的类型?