From 94c7913622f489a185564fdbad215f38e71a2366 Mon Sep 17 00:00:00 2001 From: Anders Ramsay Date: Mon, 26 Sep 2016 14:59:35 -0400 Subject: [PATCH] allow for null value iconElement --- Components/Widgets/InputGroup.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Components/Widgets/InputGroup.js b/Components/Widgets/InputGroup.js index 2b75ce1e9..3e95b24c6 100644 --- a/Components/Widgets/InputGroup.js +++ b/Components/Widgets/InputGroup.js @@ -68,7 +68,6 @@ export default class InputGroup extends NativeBaseComponent { } prepareRootProps() { - var type = { paddingLeft: (this.props.borderType === 'rounded' && !this.props.children.type == Icon) ? 15 : (this.props.children.type == Icon ) ? this.getTheme().inputPaddingLeftIcon : 5 @@ -89,7 +88,6 @@ export default class InputGroup extends NativeBaseComponent { } getIconProps(icon) { - var defaultStyle = { fontSize: (this.props.toolbar || this.props.atoolbar) ? this.getTheme().toolbarIconSize : 27, alignSelf: 'center', @@ -126,10 +124,10 @@ export default class InputGroup extends NativeBaseComponent { renderChildren() { - var inputProps = {}; var newChildren = []; var childrenArray = React.Children.toArray(this.props.children); + console.log('childrenArray: ', this.props.children) var iconElement = []; iconElement = _.remove(childrenArray, function(item) { @@ -166,7 +164,7 @@ export default class InputGroup extends NativeBaseComponent { if(Array.isArray(this.props.children)) { - if(this.props.iconRight) { + if(this.props.iconRight && iconElement.length > 0) { if(clonedInp) { newChildren.push(clonedInp); } @@ -211,7 +209,9 @@ export default class InputGroup extends NativeBaseComponent { } )); } else { - newChildren.push(React.cloneElement(iconElement[0], this.getIconProps(iconElement[0]))); + if(iconElement.length > 0){ + newChildren.push(React.cloneElement(iconElement[0], this.getIconProps(iconElement[0]))); + } if(clonedInp) { newChildren.push(clonedInp); }