Search code examples
react-nativetextinputonpress

how to setup Onpress On Textinput in react-native


I am developing an app on react native. I want to call a date picker when i press on a Text-Input and after selecting a date it should show on the Text-Input


Solution

  • You cannot explicitly call onPress for TextInput. You could only use. onFocus which will be called when you press the input box to get cursor over there. No need to focus on onBlur as your use case doesn't required.. Handle close within onFocus if possible.

    onFocus = () => {
      // do something
    }
    
    render() {
      <TextInput onFocus={onFocus} />
    }