From c0cead0c50598a5a89b18ee81ea5b54bd7d3cbcc Mon Sep 17 00:00:00 2001 From: Andy Ng Date: Sun, 18 Feb 2018 20:21:18 +0700 Subject: [PATCH] Added ref for TextInput --- components/TextInput.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/components/TextInput.js b/components/TextInput.js index 6a2cebbe..0ad305ec 100644 --- a/components/TextInput.js +++ b/components/TextInput.js @@ -1,15 +1,15 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { TextInput as RNTextInput } from 'react-native'; +import PropTypes from "prop-types"; +import React, { Component } from "react"; +import { TextInput as RNTextInput } from "react-native"; -import { connectStyle } from '@shoutem/theme'; -import { connectAnimation } from '@shoutem/animation'; +import { connectStyle } from "@shoutem/theme"; +import { connectAnimation } from "@shoutem/animation"; class TextInput extends Component { render() { const { props } = this; const style = { - ...props.style, + ...props.style }; delete style.placeholderTextColor; delete style.selectionColor; @@ -19,6 +19,11 @@ class TextInput extends Component { { + if (typeof this.props.inputRef === "function") { + this.props.inputRef(input); + } + }} placeholderTextColor={props.style.placeholderTextColor} selectionColor={props.style.selectionColor} underlineColorAndroid={props.style.underlineColorAndroid} @@ -29,12 +34,10 @@ class TextInput extends Component { TextInput.propTypes = { ...RNTextInput.propTypes, - style: PropTypes.object, + style: PropTypes.object }; const AnimatedTextInput = connectAnimation(TextInput); -const StyledTextInput = connectStyle('shoutem.ui.TextInput')(AnimatedTextInput); +const StyledTextInput = connectStyle("shoutem.ui.TextInput")(AnimatedTextInput); -export { - StyledTextInput as TextInput, -}; +export { StyledTextInput as TextInput };