Skip to content

Instantly share code, notes, and snippets.

@andreferi3
Created May 4, 2020 17:14
Show Gist options
  • Select an option

  • Save andreferi3/527e876da98163deb97b032a28fae794 to your computer and use it in GitHub Desktop.

Select an option

Save andreferi3/527e876da98163deb97b032a28fae794 to your computer and use it in GitHub Desktop.
// variable to hold the references of the textfields
inputs = {};
// function to focus the field
focusTheField = (id) => {
this.inputs[id].focus();
}
// upon submitting the Field 1, we want to focus the Field 2
render() {
return (
<>
<TextInput
label={"Field 1"}
blurOnSubmit={ false }
returnKeyType={ 'next' }
onSubmitEditing={() => { this.focusTheField('field2'); }}
/>
<TextInput
ref={input => { this.inputs['field2'] = input }}
label={"Field 2"}
/>
</>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment