当改变数组中的字段时,其余字段消失,如何渲染?
When change field in array, rest fields disappear, how to render it?
我有 FieldArray
并且每个项目生成 :
export const Options = (props) => { return <div>{
props.fields.map((op, index) =>
<Fields
key={index}
names={[
`${props.fields.name}[${index}].${op.fieldName}`,
`${props.fields.name}[${index}].optionSubList`,
`${props.fields.name}[${index}].otherValue`
]}
component={SelectList}
otherValue={op.otherValue}
fieldName={op.fieldName}
important={op.required}
className={op.classNames}
label={op.label}
list={op.options}
/>
) }</div>; };
我更改其中一个字段后,其他字段消失了。
我尝试添加 initialValue:这不起作用,如果我还缺少一个剩余字段也是如此
我也放了一个flag enableReinitialize一样
我有点担心你的 [${index}]
包含,因为 props.fields.name
的末尾应该已经有一个 [42]
类型索引。我不知道相邻组件的所有详细信息,但我建议删除索引。
<Fields
key={index}
names={[
`${props.fields.name}.${op.fieldName}`,
`${props.fields.name}.optionSubList`,
`${props.fields.name}.otherValue`
]}
.../>
我有 FieldArray
并且每个项目生成 :
export const Options = (props) => { return <div>{
props.fields.map((op, index) =>
<Fields
key={index}
names={[
`${props.fields.name}[${index}].${op.fieldName}`,
`${props.fields.name}[${index}].optionSubList`,
`${props.fields.name}[${index}].otherValue`
]}
component={SelectList}
otherValue={op.otherValue}
fieldName={op.fieldName}
important={op.required}
className={op.classNames}
label={op.label}
list={op.options}
/>
) }</div>; };
我更改其中一个字段后,其他字段消失了。
我尝试添加 initialValue:这不起作用,如果我还缺少一个剩余字段也是如此
我也放了一个flag enableReinitialize一样
我有点担心你的 [${index}]
包含,因为 props.fields.name
的末尾应该已经有一个 [42]
类型索引。我不知道相邻组件的所有详细信息,但我建议删除索引。
<Fields
key={index}
names={[
`${props.fields.name}.${op.fieldName}`,
`${props.fields.name}.optionSubList`,
`${props.fields.name}.otherValue`
]}
.../>