React semantic UI:如何为下拉元素的输入字段设置焦点

React semantic UI: How to set focus for input field of dropdown element

是否可以最初将焦点设置到 Dropdown 元素的输入字段?

<Dropdown
  name={name}
  placeholder='Select type'
  search
  searchInput={{ type: 'text' }}
  selection
  onChange={this.handleChange}
  options={options}
/>

因此用户应该能够启动 typing/searching 而无需单击下拉输入字段...

如果我对你的问题的理解正确,你想在加载内容时让你的 Dropdown 组件获得焦点吗?

如果情况确实如此,那么您要使用 Refs。有关详细示例,请参见以下内容: Refs and the DOM

特别是:

When to Use Refs

There are a few good use cases for refs:

  • Managing focus, text selection, or media playback.
  • Triggering imperative animations.
  • Integrating with third-party DOM libraries.