Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

returnKeyType = "next" issue in react native

I am using returnKeyType = "next" in TextInput component, but it is working like returnKeyType="go" instead of moving to the next textinput field.

How can we move from one textinput field to next textinput field using the "next" button on the keyboard?

like image 971
Lovedeep Singh Avatar asked Jan 17 '18 12:01

Lovedeep Singh


1 Answers

You need to set focus on the next textfield using the reference like this:

<View style={{flex:1}}>
    <TextInput style={{height:40}} 
        placeholder="First TextField Input"
        placeholderTextColor="#DCDCDC"
        returnKeyType="next"
        onSubmitEditing={()=>this.secondTextInput.focus()}/>
    <TextInput style={{height:40}} 
        placeholder="Second TextField Input"
        placeholderTextColor="#DCDCDC"
        returnKeyType="go"
        ref={(input)=>this.secondTextInput = input}/> 
</View>
like image 174
Himanshu Dwivedi Avatar answered Nov 17 '22 05:11

Himanshu Dwivedi