Tuesday, May 21, 2024
 Popular · Latest · Hot · Upcoming
86
rated 0 times [  92] [ 6]  / answers: 1 / hits: 15820  / 6 Years ago, sun, april 1, 2018, 12:00:00

From the Facebook React Native Text Input documentation, I was able to discern that this is what happens when onSubmitEditing is used:




Callback that is called when the text input's submit button is pressed.




However, there wasn't anything for onChangeText. I'm assuming if the text has changed, then it will trigger.



Why would I want to use one other than the other? For example if I'm making something that takes in text for the TextInput field, wouldn't I just want to use onChangeText? In some examples I've seen them use onSubmitEditing and I'm confused on why you would use one over the other. This question is different than wondering how to make the submit button - I'm asking why I would use onChangeText vs. onSubmitEditing.


More From » reactjs

 Answers
4

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.



For example, you might need some validation on every key press, in that case you will use onChangeText, if you need the validation to trigger when you finish typing, you need onSubmitEditing



In your example, you will achieve what you need in both cases.


[#54804] Wednesday, March 28, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
benitoh

Total Points: 150
Total Questions: 113
Total Answers: 104

Location: India
Member since Wed, Aug 26, 2020
4 Years ago
;