简体   繁体   中英

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

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?

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}/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM