In React Native when using the keyboard, once a user hits return to submit text to signify they are done typing something in the input, how would I call a function from the keyboard return event touch?
returnKeyboardClick(){
//how to call this when user clicks return on keyboard?
}
render(){
return (
<View style={styles.container}>
<TextInput
style={styles.input}
onChangeText={this.inputTextEnter}
placeholder='Type Here'
placeholderTextColor='#000'
keyboardType='default'
/>
</View>
);
}
Two methods exposed via the native element are .focus() and .blur() that will focus or blur the TextInput programmatically.
Use the maxLength prop to set a character limit on an input field in React, e.g. <input maxLength={5} /> . The maxLength attribute defines the maximum number of characters the user can enter into an input field or a textarea element.
You should call the onSubmitEditing function.
myFunction() {
// do something
}
<TextInput onSubmitEditing={ () => this.myFunction() } />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With