Unfocus a TextInput in React Native

后端 未结 6 1584
我寻月下人不归
我寻月下人不归 2020-12-29 20:44

I\'m building an Android app with React Native.

How can you force a TextInput to \"unFocus\", meaning the cursor is blinking inside the text field. The

6条回答
  •  滥情空心
    2020-12-29 21:04

    I managed to solve this with this.ref reference. First, you assign to the TextInput a ref, like this:

    
    

    Then, you call the blur() method to this.refs.myInput from a function

     blurTextInput(){
        this.refs.myInput.blur()
     }
    

提交回复
热议问题