refactor: remove propTypes in private components

This commit is contained in:
Benjy Cui 2016-10-24 16:51:53 +08:00
parent 08e21e0a2f
commit e9111a855f
3 changed files with 16 additions and 46 deletions

View File

@ -13,26 +13,25 @@ function getNumberArray(num) {
.map(i => Number(i)) : [];
}
export default class ScrollNumber extends Component<any, any> {
export interface ScrollNumberProps {
prefixCls?: string;
className?: string;
count?: string | number;
component?: string;
onAnimated?: Function;
height?: number;
style: React.CSSProperties;
}
export default class ScrollNumber extends Component<ScrollNumberProps, any> {
static defaultProps = {
prefixCls: 'ant-scroll-number',
count: null,
component: 'sup',
onAnimated() {
},
height: 18,
};
static propTypes = {
count: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.number,
]),
component: React.PropTypes.string,
onAnimated: React.PropTypes.func,
height: React.PropTypes.number,
};
lastCount: any;
constructor(props) {
@ -85,7 +84,10 @@ export default class ScrollNumber extends Component<any, any> {
animateStarted: false,
count: nextProps.count,
}, () => {
this.props.onAnimated();
const onAnimated = this.props.onAnimated;
if (onAnimated) {
onAnimated();
}
});
}, 5);
});
@ -138,7 +140,7 @@ export default class ScrollNumber extends Component<any, any> {
className: `${this.props.prefixCls} ${this.props.className}`,
});
return createElement(
this.props.component,
this.props.component || 'sup',
props,
this.renderNumberElement()
);

View File

@ -1,5 +1,4 @@
import React from 'react';
import { PropTypes } from 'react';
import moment from 'moment';
import { PREFIX_CLS } from './Constants';
import Select from '../select';
@ -25,19 +24,6 @@ export default class Header extends React.Component<HeaderProps, any> {
yearSelectTotal: 20,
};
static propTypes = {
value: PropTypes.object,
locale: PropTypes.object,
yearSelectOffset: PropTypes.number,
yearSelectTotal: PropTypes.number,
onValueChange: PropTypes.func,
onTypeChange: PropTypes.func,
prefixCls: PropTypes.string,
selectPrefixCls: PropTypes.string,
type: PropTypes.string,
fullscreen: PropTypes.bool,
};
getYearSelectElement(year) {
const { yearSelectOffset, yearSelectTotal, locale, prefixCls, fullscreen } = this.props;
const start = year - yearSelectOffset;

View File

@ -1,5 +1,4 @@
import React from 'react';
import { PropTypes } from 'react';
import Checkbox from '../checkbox';
import Search from './search';
import classNames from 'classnames';
@ -52,23 +51,6 @@ export default class TransferList extends React.Component<TransferListProps, any
render: noop,
};
static propTypes = {
prefixCls: PropTypes.string,
dataSource: PropTypes.array,
showSearch: PropTypes.bool,
filterOption: PropTypes.func,
searchPlaceholder: PropTypes.string,
titleText: PropTypes.string,
style: PropTypes.object,
handleClear: PropTypes.func,
handleFilter: PropTypes.func,
handleSelect: PropTypes.func,
handleSelectAll: PropTypes.func,
render: PropTypes.func,
body: PropTypes.func,
footer: PropTypes.func,
};
static contextTypes = {
antLocale: React.PropTypes.object,
};