46074

Show keyboard programatically using React native

Question:

How do I show Keyboard for TextInput programatically using react native? Using a ScrollView, tapping between TextInput causes the keyboard to be dismissed. I want to show the Keyboard again using onFocus method of TextInput. Anyway to accomplish this?

Answer1:

consider have a reference of your textInput :

<TextInput ref={(ref)=>{this.myTextInput = ref}} />

And when you have to focus it again use : this.myTextInput.focus()

<strong>edit React16</strong>

For react16 use React.createRef to create a reference.

Answer2:

Your ScrollView needs to include the <strong>keyboardShouldPersistTaps</strong> prop:

<ScrollView keyboardShouldPersistTaps></ScrollView>

Recommend

  • Pull specific revision from master branch?
  • compile-time safe array in C++?
  • Understanding GetDiBits. C++
  • JGit/EGit crashing on branch deletion/creation
  • how to change process (application) priority from Normal to Low Programmatically in Golang
  • SQL query to select percentage of total
  • structure expected on left side of . or .* but it is a structure
  • create new controller - error running selected code generator
  • Create object from array of keys and values
  • Multiple database in single query is possible?
  • Java: Read certificates from windows store
  • Feed ocamlyacc parser from explicit token list?
  • Perl6: Constructors in subclases
  • Recognize CheckedListBox item has been selected
  • Left join on date range by group ID
  • How to store a php array on the client side?
  • How to list all Call logs from Log list including Sms and email logs also?
  • Post-receive hook to pull from bare repo
  • dropdown value null when using, viewmodel & modelbinder in asp.net mvc
  • IE6 postback in asp.net
  • How to use InjectTouchInput for specific window?
  • How to change Language in android WebView
  • Plotting multiple variables from same data frame in ggplot [duplicate]
  • Error: packet sequence number wrong after upgrading RDS instance
  • Java: How to refer to subclass's static variable in abstract class?
  • How do I force ASP.NET Ajax to use a script from the FS and not WebResource.axd, or to reduce its HT
  • Max execution time error
  • Find string between two substrings AND between string and the end of file
  • Redmine can't generate secret token
  • Get an image from the video
  • Signed Java web start application with Glassfish 4.1 and Java7
  • Autocomplete source from project settings
  • Add font awesome icon to custom add to cart button in Woocommerce 3
  • How to specify generic type when the type is only known at runtime?
  • How to integrate angular2-material (alpha 8.2) with angular2-Quickstart app
  • Android Library Projects on Windows and Mac