type(button): fix icon/onClick proptype

This commit is contained in:
George Lima 2019-01-21 21:07:28 -03:00
parent a61e2a69b5
commit 793a116106
1 changed files with 8 additions and 11 deletions

View File

@ -70,7 +70,7 @@ type Props = {
to?: ?string,
variant?: 'primary' | 'secondary',
disabled?: boolean,
icon?: string,
icon?: string | null,
className?: string,
isLoading?: boolean,
};
@ -88,24 +88,21 @@ export const Button = ({
if (to && onClick) throw new Error('Should define either "to" or "onClick"');
const props = {
onClick, disabled: disabled || isLoading, icon: null, className,
onClick,
disabled: disabled || isLoading,
icon: null,
className,
};
const buttonLabel = isLoading ? 'Loading...' : label;
const component = variant === 'primary' ? (
<Primary {...props}>
{icon
? <Icon src={icon} />
: null
}
{icon ? <Icon src={icon} /> : null}
{buttonLabel}
</Primary>
) : (
<Secondary {...props}>
{icon
? <Icon src={icon} />
: null
}
{icon ? <Icon src={icon} /> : null}
{buttonLabel}
</Secondary>
);
@ -117,7 +114,7 @@ Button.defaultProps = {
to: '',
icon: null,
variant: 'primary',
onClick: null,
onClick: () => {},
disabled: false,
className: '',
isLoading: false,