hide badge when count is 0, fix #476

This commit is contained in:
afc163 2015-11-04 18:00:14 +08:00
parent ee272e33bb
commit 27155b5d81
4 changed files with 6 additions and 5 deletions

View File

@ -10,10 +10,10 @@
import { Badge } from 'antd';
ReactDOM.render(<div>
<Badge count="99">
<Badge count={99}>
<a href="#" className="head-example"></a>
</Badge>
<Badge count="200">
<Badge count={200}>
<a href="#" className="head-example"></a>
</Badge>
</div>, document.getElementById('components-badge-demo-99plus'));

View File

@ -10,7 +10,7 @@
import { Badge } from 'antd';
ReactDOM.render(
<Badge count="5">
<Badge count={5}>
<a href="#" className="head-example"></a>
</Badge>
, document.getElementById('components-badge-demo-basic'));

View File

@ -11,7 +11,7 @@ import { Badge } from 'antd';
ReactDOM.render(
<a href="#">
<Badge count="5">
<Badge count={5}>
<span className="head-example"></span>
</Badge>
</a>

View File

@ -14,7 +14,8 @@ class AntBadge extends React.Component {
</span>;
}
let count = this.props.count;
if (!count) {
// null undefined "" "0" 0
if (!count || count === '0') {
return cloneElement(this.props.children);
} else {
count = count >= 100 ? '99+' : count;