Created
January 23, 2017 14:31
-
-
Save souhe/da463d3e5eb50a684292c5680371ccd0 to your computer and use it in GitHub Desktop.
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
import React, { Component } from 'react'; | |
import { TextInput } from 'react-native'; | |
import selectable from './selectable'; | |
const Selectable = selectable(TextInput); // The most important line in this implementation! | |
export default class SelectableInput extends Component { | |
_input: any | |
_handleInputPress = () => { | |
this._input.focus(); | |
} | |
handleSubmit = () => { | |
this._input.blur(); | |
} | |
render() { | |
return ( | |
<Selectable | |
onPress={this._handleInputPress} | |
onSubmitEditing={this.handleSubmit} | |
ref={i => (this._input = i ? i._wrappedComponent : null)} | |
{...this.props} | |
/> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment