From 2793cae23b646c6895e76b3d08a0dcf1d421c140 Mon Sep 17 00:00:00 2001 From: Ben-hur Santos Ott Date: Mon, 14 Aug 2017 21:44:32 -0300 Subject: [PATCH] fix(customTextInput): fixing duplicated element --- README.md | 3 +++ lib/text-input-mask.js | 17 ++++++++--------- package.json | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index da98ed3a..9d7f543b 100644 --- a/README.md +++ b/README.md @@ -404,6 +404,9 @@ var money = MaskService.toMask('money', '123', { # Changelog +## 1.6.1 +* Fixing duplicated custom text input component. (thanks to [Pablo](https://github.com/rochapablo)) + ## 1.6.0 * Add compatibility to [react-native-textinput-effects](https://github.com/halilb/react-native-textinput-effects) by using `customTextInputProps` (thanks to [Pablo](https://github.com/rochapablo)) diff --git a/lib/text-input-mask.js b/lib/text-input-mask.js index 91a53f9b..528ccf8a 100644 --- a/lib/text-input-mask.js +++ b/lib/text-input-mask.js @@ -7,16 +7,7 @@ import BaseTextComponent from './base-text-component'; const INPUT_TEXT_REF = '$input-text'; -let Input = TextInput -let customTextInputProps = {} - export default class TextInputMask extends BaseTextComponent { - constructor(props) { - super(props); - if (props.customTextInput) Input = props.customTextInput - if (props.customTextInputProps) customTextInputProps = props.customTextInputProps - } - getElement() { return this.refs[INPUT_TEXT_REF]; } @@ -49,6 +40,14 @@ export default class TextInputMask extends BaseTextComponent { } render() { + let Input = TextInput + let customTextInputProps = {} + + if (this.props.customTextInput) { + Input = this.props.customTextInput + customTextInputProps = this.props.customTextInputProps || {} + } + return (