爲什麼他們在這裏使用componentWillUnmount
到clearInterval
?「componentWillUnmount」如何以清除間隔工作?
componentWillUnmount() {
clearInterval(this.timerID);
console.log("here"); //nothing happens
}
in this example at the official docs
爲什麼他們使用它,因爲這種方法不會被調用在這個週期,因此調用clearInterval不會每秒執行一次?這不是每秒都會有一個新的時間間隔發生的想法嗎?或者我誤解?
我的回答有用嗎?如果是這樣,請隨時投票,如果它解決了您的問題,請點擊對勾。你也會得到一些代表點。 :-) –