Skip to content

Instantly share code, notes, and snippets.

@souhe
Created January 23, 2017 14:31
Show Gist options
  • Save souhe/da463d3e5eb50a684292c5680371ccd0 to your computer and use it in GitHub Desktop.
Save souhe/da463d3e5eb50a684292c5680371ccd0 to your computer and use it in GitHub Desktop.
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