mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-16 01:41:02 +08:00
29 lines
1008 B
TypeScript
29 lines
1008 B
TypeScript
import RcCheckbox from 'rc-checkbox';
|
|
import React from 'react';
|
|
import CheckboxGroup from './Group';
|
|
import classNames from 'classnames';
|
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
|
import splitObject from '../_util/splitObject';
|
|
export default class Checkbox extends React.Component {
|
|
static Group = CheckboxGroup;
|
|
static defaultProps = {
|
|
prefixCls: 'ant-checkbox',
|
|
}
|
|
shouldComponentUpdate(...args) {
|
|
return PureRenderMixin.shouldComponentUpdate.apply(this, args);
|
|
}
|
|
render() {
|
|
const [{ prefixCls, style, children, className },restProps] = splitObject(this.props, ['prefixCls', 'style', 'children', 'className']);
|
|
const classString = classNames({
|
|
[className]: !!className,
|
|
[`${prefixCls}-wrapper`]: true,
|
|
});
|
|
return (
|
|
<label className={classString} style={style}>
|
|
<RcCheckbox {...restProps} prefixCls={prefixCls} children={null} />
|
|
{children !== undefined ? <span>{children}</span> : null}
|
|
</label>
|
|
);
|
|
}
|
|
}
|