извлекает содержимое componentWillMount и помещает его в другую функцию:
componentWillMount() {
this.foo();
}
foo() {
this.timer = setInterval(this.countDown, 1000);
this.setState({ seconds: this.props.time });
}
, затем вы должны вызвать this.foo (), когда интервал достигает 0:
this.interval = setInterval(() => {
this.setState({ currentCount: this.state.currentCount - 1 });
if (this.state.currentCount === 0) {
clearInterval(this.interval);
this.setState({ visible: false });
this.foo();
}
}, 1000);