how react programmatically focus input

前端 未结 6 2084
滥情空心
滥情空心 2020-12-15 03:01

I\'m trying to implement a very simple use case, a UI feature, where:

  1. There is a label with some content in it
  2. If clicked, a text input replaces it wi
6条回答
  •  借酒劲吻你
    2020-12-15 03:40

    Use componentDidUpdate method to every time update the component

    componentDidUpdate(prevProps, prevState) {
         this.input.focus();
    }
    

提交回复
热议问题