Last active
May 24, 2020 01:45
-
-
Save topherPedersen/2ed7eb64e85b797ab85a796a9a506f3a to your computer and use it in GitHub Desktop.
TextInput autoFocus work-around for use in React-Native Modals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Modal | |
visible={true} | |
onShow={ () => { this.textInput.focus(); }}> | |
{/* Adapted From: https://stackoverflow.com/questions/42730400/focus-input-on-load-of-modal-in-react-native */} | |
<KeyboardAvoidingView style={{}}> | |
<TextInput | |
style={{}} | |
ref={ (input) => { this.textInput = input; }} | |
placeholder=" Enter Text Here" | |
onChangeText={ (text) => console.log(text) } | |
value={ null } /> | |
<Button | |
title="Submit" | |
onPress={ () => console.log("do stuff...") } /> | |
</KeyboardAvoidingView> | |
</Modal> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment