Skip to content

Commit 240e64b

Browse files
author
Minh Tran
committed
Merge pull request #3 from deniss-muhla/patch-1
Missing clearTimeout()
2 parents c725d61 + 5d5d964 commit 240e64b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/ProgressBar.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,18 @@ class ProgressBar extends React.Component {
3232
if (this.interval) {
3333
clearInterval(this.interval);
3434
}
35+
if (this.timeout) {
36+
clearTimeout(this.timeout);
37+
}
3538
};
3639

3740
componentWillReceiveProps = (nextProps) => {
3841
if (this.interval) {
3942
clearInterval(this.interval);
4043
}
44+
if (this.timeout) {
45+
clearTimeout(this.timeout);
46+
}
4147

4248
if (nextProps.autoIncrement && nextProps.percent >= 0 && nextProps.percent < 99) {
4349
this.interval = setInterval(this.increment, nextProps.intervalTime);
@@ -47,7 +53,7 @@ class ProgressBar extends React.Component {
4753
this.setState({
4854
percent: 99.9
4955
}, () => {
50-
setTimeout(() => {
56+
this.timeout = setTimeout(() => {
5157
this.setState({
5258
percent: -1
5359
});

0 commit comments

Comments
 (0)