Browse Source

fix: get count from props

pull/443/head
haoxin 9 years ago
parent
commit
147ffa4209
  1. 8
      components/badge/index.jsx

8
components/badge/index.jsx

@ -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>

Loading…
Cancel
Save