react-countup
Advanced tools
Comparing version 4.2.1 to 4.2.2
@@ -334,4 +334,12 @@ 'use strict'; | ||
value: function shouldComponentUpdate(nextProps) { | ||
var hasCertainPropsChanged = this.props.duration !== nextProps.duration || this.props.end !== nextProps.end || this.props.start !== nextProps.start; | ||
return hasCertainPropsChanged || this.props.redraw; | ||
var _this$props3 = this.props, | ||
end = _this$props3.end, | ||
start = _this$props3.start, | ||
suffix = _this$props3.suffix, | ||
prefix = _this$props3.prefix, | ||
redraw = _this$props3.redraw, | ||
duration = _this$props3.duration, | ||
separator = _this$props3.separator; | ||
var hasCertainPropsChanged = duration !== nextProps.duration || end !== nextProps.end || start !== nextProps.start || suffix !== nextProps.suffix || prefix !== nextProps.prefix || separator !== nextProps.separator; | ||
return hasCertainPropsChanged || redraw; | ||
} | ||
@@ -341,6 +349,16 @@ }, { | ||
value: function componentDidUpdate(prevProps) { | ||
// If duration or start has changed, there's no way to update the duration | ||
// or start value. So we need to re-create the CountUp instance in order to | ||
// If duration, suffix, prefix, separator or start has changed | ||
// there's no way to update the values. | ||
// So we need to re-create the CountUp instance in order to | ||
// restart it. | ||
if (this.props.duration !== prevProps.duration || this.props.start !== prevProps.start) { | ||
var _this$props4 = this.props, | ||
end = _this$props4.end, | ||
start = _this$props4.start, | ||
suffix = _this$props4.suffix, | ||
prefix = _this$props4.prefix, | ||
duration = _this$props4.duration, | ||
separator = _this$props4.separator, | ||
preserveValue = _this$props4.preserveValue; | ||
if (duration !== prevProps.duration || start !== prevProps.start || suffix !== prevProps.suffix || prefix !== prevProps.suffix || separator !== prevProps.separator) { | ||
this.instance.reset(); | ||
@@ -353,8 +371,8 @@ this.instance = this.createInstance(); | ||
if (this.props.end !== prevProps.end) { | ||
if (!this.props.preserveValue) { | ||
if (end !== prevProps.end) { | ||
if (!preserveValue) { | ||
this.instance.reset(); | ||
} | ||
this.instance.update(this.props.end); | ||
this.instance.update(end); | ||
} | ||
@@ -374,6 +392,6 @@ } | ||
value: function render() { | ||
var _this$props3 = this.props, | ||
children = _this$props3.children, | ||
className = _this$props3.className, | ||
style = _this$props3.style; | ||
var _this$props5 = this.props, | ||
children = _this$props5.children, | ||
className = _this$props5.className, | ||
style = _this$props5.style; | ||
var containerRef = this.containerRef, | ||
@@ -380,0 +398,0 @@ pauseResume = this.pauseResume, |
{ | ||
"name": "react-countup", | ||
"version": "4.2.1", | ||
"version": "4.2.2", | ||
"description": "A React component wrapper around CountUp.js", | ||
@@ -45,9 +45,9 @@ "author": "Glenn Reyes <glenn@glennreyes.com> (https://twitter.com/glnnrys)", | ||
"babel-jest": "23.6.0", | ||
"husky": "3.0.2", | ||
"jest": "24.8.0", | ||
"husky": "3.0.3", | ||
"jest": "24.9.0", | ||
"prettier": "1.18.2", | ||
"pretty-quick": "1.11.1", | ||
"raf": "3.4.1", | ||
"react": "16.8.6", | ||
"react-dom": "16.8.6", | ||
"react": "16.9.0", | ||
"react-dom": "16.9.0", | ||
"react-testing-library": "5.4.4", | ||
@@ -54,0 +54,0 @@ "rollup": "0.68.2", |
26981
492