Home » Android » how to clear TextInput focus in React Native? (Android)

how to clear TextInput focus in React Native? (Android)

Posted by: admin June 15, 2020 Leave a comment

Questions:

how to clear TextInput focus in React Native? (Android)

I have look for an API here:

https://facebook.github.io/react-native/docs/textinput.html#content

But no result…

Anyone can help?

How to&Answers:

I think this should work. Add the onFocus as a prop to your TextInput . This is assuming you have a state variable called text, and that the TextInput takes its value from that state variable.

<TextInput 
   ...
   onFocus= {() => this.setState({text : ''})}
   value={this.state.text}/>