1

react组件对于一些异步任务的话,要及时清理,否则频繁渲染的话会造成异步任务持续增多,不会释放
解决方案
1、在componentWillUnmount时clearTimout() clearIntever()
2、在componentDidMount是clearTimout() clearIntever()之后再setTimeout() setIntever()

tips: promise无法清除掉

此外,style={{}}尽量不要使用,用className来代替


杨龙飞
45 声望2 粉丝

喜欢思考,喜欢前端,喜欢交友,喜欢玩