Merge pull request #443 from coderhaoxin/fix-badge-count

fix: get count from props
This commit is contained in:
偏右 2015-10-28 17:51:14 +08:00
commit 5ab1a16a32

View File

@ -4,10 +4,6 @@ const prefixCls = 'ant-badge';
class AntBadge extends React.Component {
constructor(props) {
super(props);
this.state = {
count: props.count
};
}
render() {
@ -17,13 +13,13 @@ class AntBadge extends React.Component {
<sup className={prefixCls + '-dot'}></sup>
</span>;
}
let count = this.state.count;
let count = this.props.count;
if (!count) {
return cloneElement(this.props.children);
} else {
count = count >= 100 ? '99+' : count;
return (
<span className={prefixCls} title={this.state.count} {...this.props}>
<span className={prefixCls} title={count} {...this.props}>
{this.props.children}
<sup className={prefixCls + '-count'}>{count}</sup>
</span>