Melissa
Melissa

Reputation: 21

react-native: can't focus in TextInput by Pressing a button

I want to focus in TextInput and make the keyboard pop up by pressing a button.But it didn't work. So how to solve it? Here is my code.

<TextInput ref="myInput"  />
<Text onPress={()=> this.refs["myInput"].focus()>custom</Text>

Upvotes: 0

Views: 4570

Answers (1)

Jigar Shah
Jigar Shah

Reputation: 6223

replace this line:

<Text onPress={()=> { this.refs.myInput.focus();} }>custom</Text>

You have not closed } brace and syntax issue

Upvotes: 3

Related Questions