Skip to content

Commit

Permalink
icon component an optional render function – nachos-ui#55
Browse files Browse the repository at this point in the history
  • Loading branch information
mtimofiiv committed Jun 4, 2019
1 parent d45b411 commit 1633b8f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/Input/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Input = props => {
theme[status]
);
let IconComponent;
if (icon) {
if (icon && typeof icon === 'string') {
IconComponent = (
<Icon
name={icon || iconStates[status]}
Expand All @@ -21,6 +21,8 @@ const Input = props => {
style={[theme.icon]}
/>
);
} else if (icon && typeof icon === 'function') {
IconComponent = icon();
}

// NOTE: Clone props and then delete Component specific props so we can
Expand Down Expand Up @@ -105,7 +107,7 @@ Input.propTypes = {
height: PropTypes.number,
style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
inputStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
icon: PropTypes.string,
icon: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
theme: PropTypes.object
};

Expand Down

0 comments on commit 1633b8f

Please sign in to comment.