We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5d951bb commit 462a55aCopy full SHA for 462a55a
src/Counter.js
@@ -25,10 +25,23 @@ export default class Counter extends Component {
25
26
componentDidMount() {
27
this.startTime = Date.now();
28
+ this.umount = false
29
+ requestAnimationFrame(this.animate.bind(this));
30
+ }
31
+
32
+ componentWillUnmount() {
33
+ this.umount = true
34
35
36
+ reset() {
37
+ this.startTime = Date.now();
38
+ this.stop = false
39
requestAnimationFrame(this.animate.bind(this));
40
}
41
42
animate() {
43
+ if (this.umount) return;
44
45
const { onComplete } = this.props;
46
47
if (this.stop) {
@@ -60,4 +73,4 @@ export default class Counter extends Component {
60
73
<Text style={style}>{value.toFixed(digits)}</Text>
61
74
);
62
75
63
-}
76
+}
0 commit comments