2016-03-21 21:16:38 +08:00
|
|
|
import RcRadio from 'rc-radio';
|
2015-08-21 18:24:09 +08:00
|
|
|
import React from 'react';
|
2016-01-21 22:45:21 +08:00
|
|
|
import classNames from 'classnames';
|
2016-06-16 22:06:06 +08:00
|
|
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
2015-08-21 18:24:09 +08:00
|
|
|
|
2016-03-28 23:21:47 +08:00
|
|
|
export default class Radio extends React.Component {
|
|
|
|
static defaultProps = {
|
2016-05-11 09:32:33 +08:00
|
|
|
prefixCls: 'ant-radio',
|
2016-03-28 23:21:47 +08:00
|
|
|
}
|
2016-06-12 16:15:11 +08:00
|
|
|
shouldComponentUpdate(...args) {
|
|
|
|
return PureRenderMixin.shouldComponentUpdate.apply(this, args);
|
|
|
|
}
|
2015-08-21 18:24:09 +08:00
|
|
|
render() {
|
2016-03-04 12:07:17 +08:00
|
|
|
const { prefixCls, children, checked, disabled, className, style } = this.props;
|
2016-01-21 22:45:21 +08:00
|
|
|
const classString = classNames({
|
2016-04-08 15:30:49 +08:00
|
|
|
[`${prefixCls}`]: true,
|
2016-02-17 18:04:42 +08:00
|
|
|
[`${prefixCls}-checked`]: checked,
|
|
|
|
[`${prefixCls}-disabled`]: disabled,
|
2016-01-21 22:45:21 +08:00
|
|
|
[className]: !!className,
|
|
|
|
});
|
2015-08-21 18:24:09 +08:00
|
|
|
return (
|
2016-03-04 12:07:17 +08:00
|
|
|
<label className={classString} style={style}>
|
2016-03-21 21:16:38 +08:00
|
|
|
<RcRadio {...this.props} style={null} children={null} />
|
2016-04-14 14:23:12 +08:00
|
|
|
{children ? <span>{children}</span> : null}
|
2015-08-21 18:24:09 +08:00
|
|
|
</label>
|
|
|
|
);
|
|
|
|
}
|
2016-03-28 23:21:47 +08:00
|
|
|
}
|