From 250836371bfb38e7a10235a0be1c623a5d8ddc0e Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 20 Nov 2015 21:44:05 +0800 Subject: [PATCH] improve code style --- components/badge/AntNumber.jsx | 19 +++++++++++-------- components/badge/demo/change.md | 12 ++++++++---- components/badge/index.jsx | 4 +--- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/components/badge/AntNumber.jsx b/components/badge/AntNumber.jsx index b6dd706991..aefc786cd7 100644 --- a/components/badge/AntNumber.jsx +++ b/components/badge/AntNumber.jsx @@ -1,6 +1,6 @@ -import React, {createElement} from 'react'; -import {findDOMNode} from 'react-dom'; -import {toArrayChildren, getPartNumber, getTranslateY} from './utils'; +import React, { createElement } from 'react'; +import { findDOMNode } from 'react-dom'; +import { toArrayChildren, getPartNumber, getTranslateY } from './utils'; import assign from 'object-assign'; class AntNumber extends React.Component { @@ -16,15 +16,17 @@ class AntNumber extends React.Component { }; } - getNumberOnly(c, style) { + getNumberOnly(index, style) { const childrenToReturn = []; for (let i = 0; i < 30; i++) { let count = i >= 10 ? i % 10 : i; - const children =

{count}

; - childrenToReturn.push(children); + childrenToReturn.push(

{count}

); } - const key = 'only_' + c; - return createElement('span', {className: `${this.props.prefixCls}-only`, style: style, key: key}, childrenToReturn); + return createElement('span', { + className: `${this.props.prefixCls}-only`, + style: style, + key: index, + }, childrenToReturn); } setEndState(style) { @@ -106,6 +108,7 @@ class AntNumber extends React.Component { return createElement(this.props.component, props, childrenToRender); } } + AntNumber.defaultProps = { prefixCls: 'ant-number', count: null, diff --git a/components/badge/demo/change.md b/components/badge/demo/change.md index 4ce034bdab..59b7b9878e 100644 --- a/components/badge/demo/change.md +++ b/components/badge/demo/change.md @@ -33,7 +33,7 @@ const Test = React.createClass({ show: !this.state.show }); }, - onNumberClick(){ + onNumberClick() { const count = this.state.count; this.setState({ count: count ? 0 : 5 @@ -45,9 +45,15 @@ const Test = React.createClass({ - 一个链接 +
+ + - -
; } diff --git a/components/badge/index.jsx b/components/badge/index.jsx index 0057221ed8..06e3a59614 100644 --- a/components/badge/index.jsx +++ b/components/badge/index.jsx @@ -31,7 +31,7 @@ class AntBadge extends React.Component { transitionAppear={true}> { hidden ? null : - + } @@ -43,7 +43,6 @@ AntBadge.defaultProps = { prefixCls: 'ant-badge', count: null, dot: false, - animEnd: null }; AntBadge.propTypes = { @@ -52,7 +51,6 @@ AntBadge.propTypes = { React.PropTypes.number ]), dot: React.PropTypes.bool, - animEnd: React.PropTypes.func }; export default AntBadge;