我有以下代码:
render() {
let props = this.props;
console.log("props.data", props.data);
return (
<div
className={"formula-element " + (props.isSelected ? "selectedVal" : "")}
key={props.formulaElementIndex}
id={props.id}
>
<span
class="icon_sprite icon_close small_icon"
onClick={() => {
props.deleteHandler(props.formulaElementIndex);
}}
/>
{has(props.data, MEASURE_ID_SEARCH_PATH) ? (
<MeasureFormulaElement
{...props}
key={get(props.data, MEASURE_ID_SEARCH_PATH)}
/>
) : (
<div
className="formula-item"
title={props.data}
onContextMenu={e => this.showContextMenu(e)}
>
{this.state.isRightClicked && (
<ContextMenu
key={props.formulaElementIndex}
clientY={this.state.clientY}
items={this.createMenuItems(this.props.data)}
hideContextMenu={e => {
this.hideContextMenu(e);
}}
clientX={this.state.clientX}
/>
)}
{props.data}
</div>
)}
</div>
);
}
我的props.data
如下所示:
["(", {measure:[{}]}, "/", undefined, ")"]
我收到此错误:
对象作为React子对象无效(找到:带有键的对象 {测量})。如果您打算渲染儿童集合,请使用 而不是数组。
那是为什么?