简体   繁体   中英

How to set focus listener on TextInput in react native

Hi I am using TextInput in my react native application. I want to open Date Dialog on clicking on TextInput . It came in my mind if it allows to listen focus events then it may work for me.

I didn't find any word around for this. Does anyone know how to set focus listener on TextInput in react native ?

<TextInput
  style={{
    height: 40,
    borderColor: "gray",
    borderWidth: 1,
    marginTop: 8
  }}
  underlineColorAndroid="transparent"
  placeholder={strings.schedule_date}
  onKeyPress={keyPress => console.log(keyPress)}
/>

You can use onFocus prop for this. It is a Callback that is called when the text input is focused. You can read this document .

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