question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Keyboard doesn't show up when autoFocus on component mount

See original GitHub issue

Hello,

I am trying to use react-native-screens combine with react-navigation for my app for better performance, however I have a weird problem. Indeed, when I have a new page mounting with a TextInput set on autoFocus, it focused as expected but the keyboard does not show up on the screen.

If I don’t put useScreens() it works perfectly, the TextInput is focused and the Keyboard appears.

react-native: 0.59.1; react-navigation: 3.8.1; react-native-screens: 1.0.0-alpha.22; OS: Android; Device: Real;

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:21
  • Comments:43 (9 by maintainers)

github_iconTop GitHub Comments

47reactions
jslokcommented, Jul 25, 2019

Same problem here.

I’m using a settimeout in componentdidmount to trigger the focus after some milliseconds, but still not the best because there is a necessary delay. setTimeout(() => this.ref.focus(), 150) Remove autoFocus prop on the component or else it won’t work.

Looking forward to a better solution if possible.

11reactions
Luckygirlllllcommented, Jul 6, 2019

Any updates for this problem? I have this problem in Android.

I have tried to use autoFocus and ref, but it didn’t help. What workarounds did you use?

componentDidMount() {
       this.ref.focus();
   }

<TextInput
                           ref={ref => this.ref = ref}
                           autoFocus={true}
                           value={this.props.reflection}
                           onChange={ e => this.props.onChange('reflection', e) }
                       />  

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to open keyboard automatically in React Native when ...
When you use autofocus, it basically calls focus once the component mounts so it's the same exact thing. If you type and it...
Read more >
Keyboard doesn't show up when autoFocus on component mount
Hello,. I am trying to use react-native-screens combine with react-navigation for my app for better performance, however I have a weird problem.
Read more >
TextInput - React Native
TextInput. A foundational component for inputting text into the app via a keyboard. Props provide configurability for several features, ...
Read more >
Focus management with Vue refs - Learn web development
This can be disorienting for keyboard and non-visual users. ... To do that, we need to handle focus in the ToDoItem component's itemEdited() ......
Read more >
3 ways to autofocus an input in React that ALMOST always work!
Thus, if we render the input element after the component mounts, we won't focus it. In this example, imagine loading is true for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found