I have a screen in my React Native application in which I have few text fields.
I was wondering if there is any way in which on screen load my keyword opens automatically and focuses on my first text input field?
I was searching for something like stateAlwaysVisible
in android.
It is a component to solve the common problem of views that need to move out of the way of the virtual keyboard. It can automatically adjust either its height, position, or bottom padding based on the keyboard height.
The keyboard should open automatically when a <TextField />
is focused. You can use the autoFocus
prop to make it focus when the element mounts (link)
My way (there was a problem with focusing and showing a keyboard on component render)
import { InteractionManager, TextInput } from 'react-native'; ... inputRef = React.createRef(); componentDidMount() { this.focusInputWithKeyboard() } focusInputWithKeyboard() { InteractionManager.runAfterInteractions(() => { this.inputRef.current.focus() }); } render() { <TextInput ref={this.inputRef} /> }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With