【问题标题】:Prop `aria-activedescendant` did not match. react-select道具 `aria-activedescendant` 不匹配。反应选择
【发布时间】:2018-06-01 12:11:20
【问题描述】:

我最近使用 react-select,它给了我一个错误:

Proparia-activedescendantdid not match

我只是将示例复制并粘贴到 github 页面中,除此错误警告外,它运行良好。

这是我的代码

<Select
   name={this.props.name}
   value={this.state.selectedOption}
   onChange={this.handleChange}
   options={[
     { value: 'one', label: 'One' },
     { value: 'two', label: 'Two' },
   ]}
 />

【问题讨论】:

  • 有同样的错误。你找到解决办法了吗?
  • 你使用服务器端渲染了吗?我没有找到任何解决方案哈哈
  • 是的,我正在使用服务器端渲染。

标签: javascript reactjs frontend react-select


【解决方案1】:

看了下源码,发现如果不通过prop instanceIdreact-select 会生成一个新的。所以,为了摆脱警告,请传递道具。

<Select
   name={this.props.name}
   instanceId={this.props.name}
   value={this.state.selectedOption}
   onChange={this.handleChange}
   options={[
     { value: 'one', label: 'One' },
     { value: 'two', label: 'Two' },
   ]}
 />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-03-10
    • 1970-01-01
    • 1970-01-01
    • 2019-01-16
    • 1970-01-01
    • 2021-02-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多