【发布时间】:2019-08-05 21:44:10
【问题描述】:
this.state.hiring.map(h => (
<FormApp
condType={h.type}
condRef={h.ref}
label={h.name}
labelName={h.name}
name={h.id}
id={h.name}
validations={h.required == true ? [this.required] : null}
dataList={this.state[h.ref]}
onChange={this.onChangeInput}
/>
));
我想
if (h.requered == true) { return [this.required] } else { null }
我有问题
react js : TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))
【问题讨论】:
-
看起来
validations期望传递一个数组,而不是null。所以也许传递一个空数组而不是null? -
This.state.hiring 为空,您可以将招聘的初始状态设置为空数组。
-
什么是
this.state.hiring?你能更新代码吗?我敢打赌你从这行得到错误,而不是validations,因为它是你的 sn-p 中唯一的迭代部分
标签: javascript reactjs