shoutem / ui

Customizable set of components for React Native applications
Other
4.9k stars 454 forks source link

TextInput: focus is not a function #255

Open seblau opened 7 years ago

seblau commented 7 years ago

I do have a couple of TextInput fields for user registration and I would like to implement a next button on the keyboard, so that the user can focus the next TextInput field from the previous one. I did it with refs like described here: https://facebook.github.io/react-native/docs/textinput.html

When I use the TextInput component from shoutem/ui, I do get an error message (see screenshot) that the function focus is not defined. However when I import the TextInput component from react-native it works.

import { TextInput } from '@shoutem/ui';

_focusNextField(nextField) {
  this.refs[nextField].focus()
}

render() {
  <TextInput
            ref='1'
            placeholder="Email"
            returnKeyType="next"
            blurOnSubmit={false}
            onSubmitEditing={() => this._focusNextField('2')}
  />
  <TextInput
            ref='2'
            placeholder="First name"
            returnKeyType="next"
            blurOnSubmit={false}
  />
}

img_6033

Definitely-Not-Vlad commented 7 years ago

May be related to https://github.com/shoutem/ui/issues/44.

Definitely-Not-Vlad commented 7 years ago

A short update.

This improvement is being worked on via this pull request, which aims to expose React Natives text input.