diff --git a/src/components/progressbar/ProgressBar.js b/src/components/progressbar/ProgressBar.js index cc00c6f281..8ae971fa92 100644 --- a/src/components/progressbar/ProgressBar.js +++ b/src/components/progressbar/ProgressBar.js @@ -24,52 +24,40 @@ export class ProgressBar extends Component { mode: PropTypes.string }; - render() { - let className = classNames('p-progressbar p-component', this.props.className, {'p-progressbar-determinate': (this.props.mode === 'determinate'), 'p-progressbar-indeterminate': (this.props.mode === 'indeterminate')}); - if(this.props.showValue) { - let labelText = (this.props.value && typeof(this.props.value) === "number") ? this.props.value + this.props.unit : (this.props.value||""); - var label =
{labelText}
; - } + shouldComponentUpdate(nextProps) { + return this.props.value !== nextProps.value; + } - let progressbar = null; - - if(this.props.mode === 'indeterminate') { - let container = (
-
-
); + renderDeterminate() { + let className = classNames('p-progressbar p-component p-progressbar-determinate', this.props.className); - if(typeof(this.props.value) === "string") { - progressbar = (
- {label} - {container} -
); - } - else { - progressbar = (
- {label} - {container} -
); - } - } - else { - let valueText = (
); + return ( +
+
+ {this.props.showValue &&
{this.props.value + this.props.unit}
} +
+ ); + } - if(typeof(this.props.value) === "string") { - progressbar = (
- {valueText} - {label} -
); - } - else { - progressbar = (
- {valueText} - {label} -
); - } - } + renderIndeterminate() { + let className = classNames('p-progressbar p-component p-progressbar-indeterminate', this.props.className); + return ( +
+
+
+
+
+ ) + } - return progressbar; + render() { + if (this.props.mode === 'determinate') + return this.renderDeterminate(); + else if (this.props.mode === 'indeterminate') + return this.renderIndeterminate(); + else + throw new Error(this.props.mode + " is not a valid mode for the ProgressBar. Valid values are 'determinate' and 'indeterminate'"); } } \ No newline at end of file