【发布时间】:2018-07-18 11:13:05
【问题描述】:
我已将 React-Select (multi) 与 redux-form 集成。如果您选择一个值并提交,它将起作用。但是,如果您需要再次提交表单(即他们的字段无效),React-Select(multi) 有一个未定义值的数组。
<Field
ref={ref => this.refTest = ref}
className = "form-control"
name="categories"
options={
this.state.categories.map(c => {
return { value: c.id, label: c.categoryName };
})
}
onBlur={this.onBlur}
component={multiSelect}
/>
multiSelect 正在使用这个组件:
export const multiSelect = (field) => {
console.log(field);
return(
<div>
<Select
name={field.name}
{...field.input}
className="section"
multi={true}
options={field.options}>
</Select>
{field.meta.touched && field.meta.error &&
<label id="basic-error" className="validation-error-label">This field is required.</label>}
</div>
);
};
无论我做什么,第二次“提交”点击总是有一个未定义“类别”的数组。
【问题讨论】:
标签: reactjs redux-form react-select