Skip to content

Added ref for TextInput #374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions components/TextInput.js
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -19,6 +19,11 @@ class TextInput extends Component {
<RNTextInput
{...props}
style={style}
ref={input => {
if (typeof this.props.inputRef === "function") {
this.props.inputRef(input);
}
}}
placeholderTextColor={props.style.placeholderTextColor}
selectionColor={props.style.selectionColor}
underlineColorAndroid={props.style.underlineColorAndroid}
Expand All @@ -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 };