If you want to get a React Native TextInput to maintain focus after submit? Below is a working example to get React Native TextInput to maintain focus after submit.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | var NameInput = React.createClass({ getInitialState() { return { textValue: '' } }, clearAndRetainFocus: function(evt, elem) { this.setState({textValue: elem.text}); setTimeout(function() { this.setState({textValue: this.getInitialState().textValue}); this.refs.Name.focus(); }.bind(this), 0); }, render() { return( <TextInput ref='Name' value={this.state.textValue} onEndEditing={this.clearAndRetainFocus} /> ) } }); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.