fix(button): fix error where native type is overridden

This commit is contained in:
unix
2020-05-13 01:05:27 +08:00
parent da05b89fb8
commit d4d717eea5
2 changed files with 6 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ exports[`Button should render empty button correctly 1`] = `
disabled={false}
effect={true}
ghost={false}
htmlType="button"
loading={false}
shadow={false}
size="medium"
@@ -23,6 +24,7 @@ exports[`Button should render special styles 2`] = `
disabled={false}
effect={true}
ghost={false}
htmlType="button"
loading={true}
shadow={false}
size="medium"

View File

@@ -17,6 +17,7 @@ interface Props {
auto?: boolean
effect?: boolean
disabled?: boolean
htmlType?: React.ButtonHTMLAttributes<any>['type']
icon?: React.ReactNode
iconRight?: React.ReactNode
onClick?: React.MouseEventHandler<HTMLButtonElement>
@@ -26,6 +27,7 @@ interface Props {
const defaultProps = {
type: 'default' as ButtonTypes,
size: 'medium' as NormalSizes,
htmlType: 'button' as React.ButtonHTMLAttributes<any>['type'],
ghost: false,
loading: false,
shadow: false,
@@ -57,6 +59,7 @@ const Button: React.FC<React.PropsWithChildren<ButtonProps>> = ({ ...btnProps })
auto,
size,
icon,
htmlType,
iconRight,
className,
...props
@@ -115,7 +118,7 @@ const Button: React.FC<React.PropsWithChildren<ButtonProps>> = ({ ...btnProps })
return (
<button
ref={buttonRef}
type="button"
type={htmlType}
className={`btn ${className}`}
disabled={disabled}
onClick={clickHandler}