我最近使用了 react-select,它给我一个错误:
Prop
aria-activedescendant不匹配
我只是将示例复制并粘贴到 github 页面中,它运行良好,但出现此错误警告。
这是我的代码
<Select
name={this.props.name}
value={this.state.selectedOption}
onChange={this.handleChange}
options={[
{ value: 'one', label: 'One' },
{ value: 'two', label: 'Two' },
]}
/>
最佳答案
看了源码才发现如果不传prop instanceId
react-select 会生成一个新的。因此,为了摆脱警告,请传递 prop。
<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' },
]}
/>
关于javascript - Prop `aria-activedescendant` 不匹配。 react 选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47880524/