简体   繁体   English

反应js:TypeError:对象null不可迭代(无法读取属性Symbol(Symbol.iterator))

[英]react js : TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))

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 } 我想要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)) 反应js: TypeError:对象null不可迭代(无法读取属性Symbol(Symbol.iterator))

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;
        }
    });

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 × TypeError: Object is not iterable (cannot read property Symbol(Symbol.iterator)) - × TypeError: Object is not iterable (cannot read property Symbol(Symbol.iterator)) TypeError: Object is not iterable (cannot read property Symbol(Symbol.iterator)) - TypeError: Object is not iterable (cannot read property Symbol(Symbol.iterator)) 使用 React Context API 时出错:“TypeError:Object 不可迭代(无法读取属性 Symbol(Symbol.iterator))” - Error while using React Context API: "TypeError: Object is not iterable (cannot read property Symbol(Symbol.iterator))" React context throwing TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator)) - React context throwing TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator)) 如何修复:React-Context - TypeError: Object 不可迭代(无法读取属性 Symbol(Symbol.iterator)) - How to fix: React-Context - TypeError: Object is not iterable (cannot read property Symbol(Symbol.iterator)) 未捕获的类型错误:对象在 XMLHttpRequest 中不可迭代(无法读取属性 Symbol(Symbol.iterator))。<anonymous> - Uncaught TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator)) at XMLHttpRequest.<anonymous> TypeError: Object is not iterable (cannot read property Symbol(Symbol.iterator)) - 为什么? 这是什么意思? 如何解决? - TypeError: Object is not iterable (cannot read property Symbol(Symbol.iterator)) - Why? What does it mean? How to solve it? TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator)) JavaScript - TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator)) JavaScript React - 使用 Hooks 时,出现错误 - Object 不可迭代(无法读取属性 Symbol (Symbol.iterator)) - React - When using Hooks, I get an error - Object is not iterable (cannot read property Symbol (Symbol.iterator)) 获得未定义是不可迭代的(无法读取属性 Symbol(Symbol.iterator)) - getting undefined is not iterable (cannot read property Symbol(Symbol.iterator))
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM