为什么他们在这里使用componentWillUnmount
到clearInterval
?“componentWillUnmount”如何以清除间隔工作?
componentWillUnmount() {
clearInterval(this.timerID);
console.log("here"); //nothing happens
}
in this example at the official docs
为什么他们使用它,因为这种方法不会被调用在这个周期,因此调用clearInterval不会每秒执行一次?这不是每秒都会有一个新的时间间隔发生的想法吗?或者我误解?
我的回答有用吗?如果是这样,请随时投票,如果它解决了您的问题,请点击对勾。你也会得到一些代表点。 :-) –