Reputation: 4233
What is the proper way to switch to the next TextInput
in React-Native >0.44.0?
I tried it with refs and .focus()
, but this didn't work. All answers I found were outdated.
Upvotes: 0
Views: 56
Reputation: 4565
You should specify ref to the next textinput. Try this
<TextInput
placeholder="first"
placeholderTextColor="rgba(0,0,0,0.5)"
returnKeyType="next"
onSubmitEditing={() => this.second.focus()}
/>
<TextInput
placeholder="second"
placeholderTextColor="rgba(0,0,0,0.5)"
returnKeyType="done"
ref={input => (this.second = input)} // This line is important
/>
Upvotes: 3