Nativebase: Ref not working for Floating input

Created on 16 Feb 2017  路  13Comments  路  Source: GeekyAnts/NativeBase

Most helpful comment

It was a headache but finally found the solution.
cc @shivrajkumar @sankhadeeproy007
```export default class SignUpForm extends Component {

_focusInput(inputField) {
this[inputField]._root.focus();
}
render() {
return (




keyboardType='numeric'
returnKeyType='next'
getRef={(input) => this.mobileInput = input}
onSubmitEditing={() => this._focusInput('passwordInput')}
/>



secureTextEntry={true}
returnKeyType='next'
getRef={(input) => this.passwordInput = input}
onSubmitEditing={() => this._focusInput('emailInput')}
/>

...........

All 13 comments

Please check #483

I'm having this same issue actually, does not seem to be fixed. The onChange from #483 is working fine but if I try to ref the <Input ref='foo' /> using this.refs.foo._root it return undefined when floatingLabel is set as a prop on <Item />.

Works:

<Item>
  <Label>Foo</Label>
  <Input ref='bar' />
</Item>

console.log(this.refs.bar._root) 
// returns Object()

Doesn't work:

<Item floatingLabel>
  <Label>Foo</Label>
  <Input ref='bar' />
</Item>

console.log(this.refs.bar._root) 
// return undefined

Basically I need this so I can set focus on the next Input ( ie. this.refs.foo._root.focus() )

Please check this

I'm having the same issue as @carlosl on [email protected].

Did you check the above link and try out the solution?

The last comments in that link was about someone having trouble with an Input in an Item without floatingLabel, and that seems to work.

The problem is that when I add floatingLabel to the item, the Input's ref stops working.

cc @shivrajkumar

Try getRef instead of ref.
The usual ref doesn't work for floatingLabel.

I have the same problem, fix please

@shivrajkumar how to use getRef can you please give an example for floatingLabel
cc @sankhadeeproy007

It was a headache but finally found the solution.
cc @shivrajkumar @sankhadeeproy007
```export default class SignUpForm extends Component {

_focusInput(inputField) {
this[inputField]._root.focus();
}
render() {
return (




keyboardType='numeric'
returnKeyType='next'
getRef={(input) => this.mobileInput = input}
onSubmitEditing={() => this._focusInput('passwordInput')}
/>



secureTextEntry={true}
returnKeyType='next'
getRef={(input) => this.passwordInput = input}
onSubmitEditing={() => this._focusInput('emailInput')}
/>

...........

@naman03malhotra's solution verified working.
Was losing my mind trying to find the solution...thanks!

react-native-cli: 2.0.1
react-native: 0.49.5
react: 16.0.0-beta.5
native-base: 2.3.3

EDIT: Seems like it works on iOS and not Android.

proposed solution doesn't work for android.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bsiddiqui picture bsiddiqui  路  3Comments

sihemhssine picture sihemhssine  路  3Comments

kitsune7 picture kitsune7  路  3Comments

agersoncgps picture agersoncgps  路  3Comments

muthuraman007 picture muthuraman007  路  3Comments