react-select - React-select 自定义 Option 对象也不接收 innerprops.key
问题描述
在 react-select 中创建自定义选项对象时,我没有收到文档中所需的 innerProps 对象的“键”属性。https://react-select.com/props#creatable-props > 组件 > 选项。尽管如此,我还是收到了 innerprops 的其余属性(id、onClick、onMouseOver、tabIndex)和一个新的 onMouseMove。有没有人有同样的问题?
无论如何,该对象似乎都可以工作,但我害怕在没有钥匙的情况下离开 React 重新加载。
自定义选项:
function Option(props) {
return (
<MenuItem
ref={props.innerRef}
selected={props.isFocused}
component="div"
style={{
fontWeight: props.isSelected ? 500 : 400,
}}
{...props.innerProps}
>
{props.children}
</MenuItem>
);
}
解决方案
推荐阅读
- python - Tkinter NavigationToolbar2TkAgg - TypeError“标签对象不可调用”
- javascript - 通过node.js运行静态文件时,如何调用node.js文档中定义的函数?
- python - 返回其值重复的键
- ruby-on-rails - 如何使选择查询在 Rails 中相对更快?
- php - 关于 PHP/HTML 项目文件结构的困惑(带表单)
- python-3.x - Python3没有在类函数调用中添加“自我”
- c# - 如何以编程方式触发 C# DataGridView SelectionChanged 事件?
- javascript - React中变量更改时关闭和重新打开标签的清洁方式
- google-cloud-dataflow - Apache Beam Runner 用于生产中的单台机器
- python - PyQT:如何隐藏对话窗口中的每个对象