thegamenicorus / react-native-phone-input

Phone input box for React Native
https://www.npmjs.com/package/react-native-phone-input
MIT License
395 stars 450 forks source link

Can't focus phone input #54

Closed DavitVosk closed 6 years ago

DavitVosk commented 6 years ago

Hi there.

I have some problem with focusing phone input when needed. My code is following:

<PhoneInput ref={ref => (this.phoneRef = ref)} onChangePhoneNumber={this.handleMobileChange.bind(this)} />

And when I call this.phoneRef.focus() I get undefined. Please help to find a solution. Thanks

DavitVosk commented 6 years ago

ok it worked. I was missing something in my code...

bushshrub commented 5 years ago

Hey could you tell me what exactly was missing in your code? I couldn't get mine to focus for some reason, even when I ran it in componentDidMount()

DavitVosk commented 5 years ago

@xiurobert I was calling this.phoneRef.focus() instead of () => this.phoneRef.focus(). Hope this will help you too

bushshrub commented 5 years ago

I'm trying to get it to focus in componentDidMount() but I'm failing to do so on iOS only. On android, it focuses completely fine.