From e9111a855f327c8baf0a86bfabe4ac37d4dc9e38 Mon Sep 17 00:00:00 2001 From: Benjy Cui Date: Mon, 24 Oct 2016 16:51:53 +0800 Subject: [PATCH] refactor: remove propTypes in private components --- components/badge/ScrollNumber.tsx | 30 ++++++++++++++++-------------- components/calendar/Header.tsx | 14 -------------- components/transfer/list.tsx | 18 ------------------ 3 files changed, 16 insertions(+), 46 deletions(-) diff --git a/components/badge/ScrollNumber.tsx b/components/badge/ScrollNumber.tsx index 036126df9f..768dc27a48 100644 --- a/components/badge/ScrollNumber.tsx +++ b/components/badge/ScrollNumber.tsx @@ -13,26 +13,25 @@ function getNumberArray(num) { .map(i => Number(i)) : []; } -export default class ScrollNumber extends Component { +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 { 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 { 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 { className: `${this.props.prefixCls} ${this.props.className}`, }); return createElement( - this.props.component, + this.props.component || 'sup', props, this.renderNumberElement() ); diff --git a/components/calendar/Header.tsx b/components/calendar/Header.tsx index 60811083b3..9fffa57ae1 100644 --- a/components/calendar/Header.tsx +++ b/components/calendar/Header.tsx @@ -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 { 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; diff --git a/components/transfer/list.tsx b/components/transfer/list.tsx index b2e9792b1f..37821e7df0 100644 --- a/components/transfer/list.tsx +++ b/components/transfer/list.tsx @@ -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