Commit 00278519 authored by dong's avatar dong Committed by niko

repair problem: countdown will not change when target time update (#392)

parent 9d9025a5
......@@ -21,9 +21,12 @@ class CountDown extends Component {
componentWillReceiveProps(nextProps) {
if (this.props.target !== nextProps.target) {
clearTimeout(this.timer);
const { lastTime } = this.initTime(nextProps);
this.setState({
lastTime,
}, () => {
this.tick();
});
}
}
......@@ -76,18 +79,18 @@ class CountDown extends Component {
clearTimeout(this.timer);
this.setState({
lastTime: 0,
});
}, () => {
if (onEnd) {
onEnd();
}
});
} else {
lastTime -= this.interval;
this.setState({
lastTime,
});
}, () => {
this.tick();
});
}
}, this.interval);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment