完美解決 React 節流函數內存泄漏問題


import {throttle} from "lodash";
constructor(props){
super(props)
this.state={
list:[]
}
this.showScreen = throttle(this.showScreen,1000)
}
showScreen=(e)=>{
console.log(e)

}




componentWillUnmount = () => {
this.showScreen.cancel();
this.setState = (state, callback) => {
return;
};
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM