Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I know react-native's TextInput has a onsubmit callback function, but how do i actually make that submit button?

Tags:

react-native

I'd like to know how to render this button and if so is it autobound to the text in the input field ?

like image 844
Vaibhav Namburi Avatar asked Nov 30 '15 05:11

Vaibhav Namburi


People also ask

How do you select the next TextInput after pressing the Next keyboard button?

To select the next TextInput after pressing the "next" keyboard button with React Native, we can assign refs to the TextInput s we want to set focus on. And then we call focus on the ref. current of the TextInput to set focus on the input.

How do you focus TextInput in React Native?

Two methods exposed via the native element are .focus() and .blur() that will focus or blur the TextInput programmatically.

How do I use onSubmitEditing React Native?

onSubmitEditing is triggered when you click the text input submit button (keyboard button). onChangeText is triggered when you type any symbol in the text input. In your example, you will achieve what you need in both cases.


1 Answers

Basically onSumbitEditing will trigger and event provided when go button is clicked from android soft keyboard as in below example :

 <TextInput
  style={[styles.zipCode, styles.mainText]}
  returnKeyType='My Custom button'
  onSubmitEditing={(event) => this.updateText( event.nativeEvent.text
   )}/>

in above code snippet : I have action name is 'My Custom button' which will appera in soft keyboard in android and when you press that the updateText event is tiggered , thats what is the meaning on onSubmitEditing

Note : if physical keyboard is enable in android emulator so onSubmitEditing will not tigger any event since you would not be also to press virtual key which is given name as 'My Custom Button'

like image 65
KOTIOS Avatar answered Sep 29 '22 09:09

KOTIOS