我的架构有一个字段,它是无限的文本字段数组。我想完全按照最后的示例进行操作:http ://redux-form.com/6.5.0/docs/api/FieldArray.md
const renderSubFields = (member, index, fields) => (
<li key={index}>
<button
type="button"
title="Remove Member"
onClick={() => fields.remove(index)}/>
<h4>Member #{index + 1}</h4>
<Field
name={`${member}.firstName`}
type="text"
component={renderField}
label="First Name"/>
<Field
name={`${member}.lastName`}
type="text"
component={renderField}
label="Last Name"/>
</li>
)
const renderMembers = ({ fields }) => (
<ul>
<button type="button" onClick={() => fields.push({})}>Add Member</button>
{fields.map(renderSubFields)}
</ul>
)
我想这是一件相当普遍的事情,但我在 AOR 文档或演示中看不到类似的东西。有没有我遗漏的例子?