TypeError: array.concat is not a functionRedux Form:FieldArray
TypeError: array.concat is not a functionRedux Form:FieldArray
我正在尝试在我的 Redux-Form 中开发一个 FieldArray,但是当我按下按钮 'Add Policy' 时 运行 出现以下错误:
Uncaught TypeError: array.concat is not a function
我的 FieldArray 调用了一个组件:
<FieldArray name="policies" component={this.renderPolicies} />
renderPolicies() 辅助函数如下所示:
renderPolicies = ({ fields, meta }) => {
return (
<ul>
<li>
<button type="button" onClick={() => fields.push({})}>
Add Policy
</button>
{this.renderError(meta)}
</li>
{fields.map((policy, index) => (
<li key={index}>
<button
type="button"
title="Remove Policy"
onClick={() => fields.remove(index)}
/>
<h4>Policy #{index + 1}</h4>
<Field
name={`${policy}.id`}
type="text"
component={renderInput}
label="Id"
/>
</li>
))}
</ul>
);
};
您的验证函数是什么样的?看这里:https://redux-form.com/8.1.0/examples/fieldarrays/.
刚遇到同样的问题,请确保您的数组字段未初始化为 null,这就是我遇到的情况
我正在尝试在我的 Redux-Form 中开发一个 FieldArray,但是当我按下按钮 'Add Policy' 时 运行 出现以下错误:
Uncaught TypeError: array.concat is not a function
我的 FieldArray 调用了一个组件:
<FieldArray name="policies" component={this.renderPolicies} />
renderPolicies() 辅助函数如下所示:
renderPolicies = ({ fields, meta }) => {
return (
<ul>
<li>
<button type="button" onClick={() => fields.push({})}>
Add Policy
</button>
{this.renderError(meta)}
</li>
{fields.map((policy, index) => (
<li key={index}>
<button
type="button"
title="Remove Policy"
onClick={() => fields.remove(index)}
/>
<h4>Policy #{index + 1}</h4>
<Field
name={`${policy}.id`}
type="text"
component={renderInput}
label="Id"
/>
</li>
))}
</ul>
);
};
您的验证函数是什么样的?看这里:https://redux-form.com/8.1.0/examples/fieldarrays/.
刚遇到同样的问题,请确保您的数组字段未初始化为 null,这就是我遇到的情况