react-select:selecting 选项后无法映射值

react-select: can't map values after selecting an option

react-tables的

This example使用react-select作为自定义过滤器,但是将react-select的版本从v1.2.1升级到v2.1.1后,我在 select 从下拉列表中选择一个选项时出现错误 entry.map is not a function

select 组件在下面,有人知道为什么 .map 不再有效吗?

    <Select
      style={{ width: "50%", marginBottom: "20px" }}
      onChange={entry => {
        console.log(entry);
        this.setState({ select2: entry });
        this.onFilteredChangeCustom(
          entry.map(o => {
             return o.value
          }),
          "firstName"
        );
      }}
      value={this.state.select2}
      multi={true}
      options={this.state.data.map((o, i) => {
        return { id: i, value: o.firstName, label: o.firstName };
      })}
    />

Entry 是一个对象,不是一个数组,所以你不能在它上面使用 map。使用条目的值 属性 似乎可行。

<Select
      style={{ width: "50%", marginBottom: "20px" }}
      onChange={entry => {
        this.setState({ select2: entry });
        this.onFilteredChangeCustom(
          entry.value,
          "firstName"
        );
      }}
      value={this.state.select2}
      multi={true}
      options={this.state.data.map((o, i) => {
        return { id: i, value: o.firstName, label: o.firstName };
      })}
    />

删除 multi={true} 属性并将其替换为 isMulti

我遇到了同样的错误,这对我有用