我正在尝试将react-semantic-redux-form SelectField与多个选项一起使用,以便用户可以选择多个选项,如果已经设置了一个选项,则应显示为选中状态。我也正在将redux-form与semantic0ui-react一起使用。尝试包含多个选择时出现错误。
我的包含声明是:
import { SelectField } from "react-semantic-redux-form";
我的状态是:
state = {
relationships: ["some entry"],
relationshipOptions: [],
};
元素代码为:
<Grid.Column>
<Field
component={SelectField}
name="relationships"
label="Your Relationships"
options={relationshipOptions}
multiple
placeholder="Select to add a relationship"
/>
我收到如下错误
Dropdown `value` must be an array when `multiple` is set. Received type: `[object String]`.
in Dropdown
您拥有relationshipOptions
的方式是错误的,应该是对象数组,
const relationshipOptions = [
{ key: "single", value: "single", text: "single" },
{ key: "married", value: "married", text: "married" }
];
这里是工作示例,Code Sandbox