AutoFocus an input element in react JS

后端 未结 2 1033
南笙
南笙 2020-12-29 04:59

I am unable to autofocus the input tag rendered in this component. What am I missing here?

class TaskBox extends Component {
  constructor() {
    super();
          


        
2条回答
  •  囚心锁ツ
    2020-12-29 05:44

    Set an ID to the input and then use .setAttribute('autoFocus', true) to the element when you want it focused

提交回复
热议问题