我可以通过编程将react-select
聚焦,但是我无法在输入字段中选择文本。
我正在像这样引用react-select
:
const selectRef = useRef()
...
<Select
ref={selectRef}
// other props
</Select>
然后:
selectRef.current.focus()
selectRef.current.select()
[Select
]成功聚焦,但是对于第二行(我相信should work on an input
element),我得到:
input
如何在TypeError: selectRef.current.select is not a function
的react-select
字段内选择文本?
仅几处更改-:
input
而且我们可以这样访问<Select
ref={(n) => this.selectRef = n}
// other props
</Select>
-> inputValue
工作小提琴-> this.selectRef.select.props.inputValue