这是代码:
render() {
console.log(this.state.catalog.products);
if (this.state.catalog.products) {
return (
this.state.catalog.products.map((item) =>
<div>
{item.description}
</div>
)
);
} else {
return (
<div>Загрузка...</div>
);
}
}
它的输出会抛出这样的错误:
A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.
我要输出的数组是:


在这里总结一下
在 <div> 和 <closeddiv> 标签中
React 不能在没有容器的情况下渲染数组(至少现在还不能)。
return应该返回一个(!)DOM 元素或null. 您正在返回多个 DOM 元素。您需要将输出包装在某个容器中,例如div或span。或者甚至像这样缩短代码:另外的选择