React Js: Typeerror: Object Null Is Not Iterable (Cannot Read Property Symbol(Symbol. Iterator))
This. State. Hiring. Map(H => ( )); I Want to If (H. Requered == True) { Return [This. Required] } Else { Null } I Have Problem React Js: Typeerror: Object...
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}
/>
));
I want to
if (h.requered == true) { return [this.required] } else { null }
I have problem
react js : TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))
1 Answer
Maybe you can modify your code like this:
const { hiring } = this.state;
hiring instanceof Array && hiring.map(h => { // ==> Validate hiring before use it.
if (h.requered == true) {
return (
<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}
/>
);
} else {
return null;
}
});