mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-01 11:39:28 +08:00
Update button code to make it more clearer (#7929)
* remove unnecessary default value of 'size' prop * `clicked` should be a state
This commit is contained in:
parent
cf397a27f0
commit
7bc6aad1fd
@ -11,7 +11,7 @@ export interface ButtonGroupProps {
|
||||
}
|
||||
|
||||
const ButtonGroup: React.SFC<ButtonGroupProps> = (props) => {
|
||||
const { prefixCls = 'ant-btn-group', size = '', className, ...others } = props;
|
||||
const { prefixCls = 'ant-btn-group', size, className, ...others } = props;
|
||||
|
||||
// large => lg
|
||||
// small => sm
|
||||
|
@ -61,7 +61,6 @@ export default class Button extends React.Component<ButtonProps, any> {
|
||||
static defaultProps = {
|
||||
prefixCls: 'ant-btn',
|
||||
loading: false,
|
||||
clicked: false,
|
||||
ghost: false,
|
||||
};
|
||||
|
||||
@ -83,6 +82,7 @@ export default class Button extends React.Component<ButtonProps, any> {
|
||||
super(props);
|
||||
this.state = {
|
||||
loading: props.loading,
|
||||
clicked: false,
|
||||
};
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ export default class Button extends React.Component<ButtonProps, any> {
|
||||
|
||||
render() {
|
||||
const {
|
||||
type, shape, size = '', className, htmlType, children, icon, prefixCls, ghost, ...others,
|
||||
type, shape, size, className, htmlType, children, icon, prefixCls, ghost, ...others,
|
||||
} = this.props;
|
||||
|
||||
const { loading, clicked } = this.state;
|
||||
@ -159,7 +159,7 @@ export default class Button extends React.Component<ButtonProps, any> {
|
||||
|
||||
return (
|
||||
<button
|
||||
{...omit(others, ['loading', 'clicked'])}
|
||||
{...omit(others, ['loading'])}
|
||||
type={htmlType || 'button'}
|
||||
className={classes}
|
||||
onClick={this.handleClick}
|
||||
|
Loading…
Reference in New Issue
Block a user