Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native TextInput phone keyboard submit?

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>
    );
  }
like image 558
Chipe Avatar asked Jan 06 '16 08:01

Chipe


People also ask

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 you set maxLength in input type number in react-native?

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.


1 Answers

You should call the onSubmitEditing function.

myFunction() {
  // do something
}

<TextInput onSubmitEditing={ () => this.myFunction() } />
like image 144
Nader Dabit Avatar answered Sep 20 '22 18:09

Nader Dabit