diff --git a/components/progress/index.jsx b/components/progress/index.jsx
index 92d42e73b5..6d00bf8793 100644
--- a/components/progress/index.jsx
+++ b/components/progress/index.jsx
@@ -1,6 +1,5 @@
import { Circle as Progresscircle } from 'rc-progress';
import React from 'react';
-import warning from 'warning';
import Icon from '../icon';
const prefixCls = 'ant-progress';
@@ -18,11 +17,7 @@ let Line = React.createClass({
percent: React.PropTypes.number,
strokeWidth: React.PropTypes.number,
trailColor: React.PropTypes.string,
- format: React.PropTypes.oneOfType([
- React.PropTypes.node,
- React.PropTypes.string,
- React.PropTypes.func,
- ]),
+ format: React.PropTypes.func,
},
getDefaultProps() {
return {
@@ -43,35 +38,24 @@ let Line = React.createClass({
let progressInfo;
let fullCls = '';
- if (props.format) {
- warning(typeof props.format === 'function',
- 'antd.Progress props.format type is function, change format={xxx} to format={() => xxx}');
- }
-
- let text = props.format || `${props.percent}%`;
- if (typeof props.format === 'string') {
- // 向下兼容原来的字符串替换方式
- text = props.format.replace('${percent}', props.percent);
- } else if (typeof props.format === 'function') {
- text = props.format(props.percent);
- }
+ const format = props.format || (percent => `${percent}%`);
if (props.showInfo) {
if (props.status === 'exception') {
progressInfo = (
- {props.format ? text : }
+ {props.format ? format(props.percent) : }
);
} else if (props.status === 'success') {
progressInfo = (
- {props.format ? text : }
+ {props.format ? format(props.percent) : }
);
} else {
progressInfo = (
- {text}
+ {format(props.percent)}
);
}
} else {
@@ -102,11 +86,7 @@ let Circle = React.createClass({
strokeWidth: React.PropTypes.number,
width: React.PropTypes.number,
trailColor: React.PropTypes.string,
- format: React.PropTypes.oneOfType([
- React.PropTypes.node,
- React.PropTypes.string,
- React.PropTypes.func,
- ]),
+ format: React.PropTypes.func,
},
getDefaultProps() {
return {
@@ -130,35 +110,24 @@ let Circle = React.createClass({
fontSize: props.width * 0.16 + 6
};
let progressInfo;
- let text = props.format || `${props.percent}%`;
- if (props.format) {
- warning(typeof props.format === 'function',
- 'antd.Progress props.format type is function, change format={xxx} to format={() => xxx}');
- }
-
- if (typeof props.format === 'string') {
- // 向下兼容原来的字符串替换方式
- text = props.format.replace('${percent}', props.percent);
- } else if (typeof props.format === 'function') {
- text = props.format(props.percent);
- }
+ const format = props.format || (percent => `${percent}%`);
if (props.status === 'exception') {
progressInfo = (
- {props.format ? text : }
+ {props.format ? format(props.percent) : }
);
} else if (props.status === 'success') {
progressInfo = (
- {props.format ? text : }
+ {props.format ? format(props.percent) : }
);
} else {
progressInfo = (
- {text}
+ {format(props.percent)}
);
}