我目前正在尝试使用自定义迭代器来显示嵌套视图。问题是,当我尝试使用ReferenceManyField并返回错误时:
TypeError:无法读取未定义的属性“ id”;
render() {
return (
<span>
<div>
{console.log(this.props)}
{this.state.datafeed.records.map((element, index) => {
return (
<Col md={12} style={{ borderBottom: "1px solid black" }}>
<Row>
<Col md={3}>
<TextField record={element.property} source="name" label="property name" />
<TextField record={element.property} source="otherProperty" label="otherProperty name" />
</Col>
<Col md={3}>
<ImageField record={element.image} source="image" />
</Col>
<Col md={3}>
<ReferenceManyField label="SomeLabel" reference="reference" target="id" >
<SingleFieldList>
<ChipField source="name" />
</SingleFieldList>
</ReferenceManyField>
</Col>
<Col md={3}>
<DeleteButton resource="resource" basePath={this.props.basePath} record={element.property} label="Delete" />
<EditButton resource="resource" basePath={this.props.basePath} record={element.property} label="Edit" />
</Col>
</Row>
</Col>
);
})}
</div>
<Button color="primary" onClick={(e) => { e.preventDefault(); this.pushNewRecord(this.state.datafeed.records); }} style={{ margin: "5px 0" }}><ContentCreateIcon /> Add new record</Button>
</span>);
}
我该如何解决?还有其他选择吗?