react组件对于一些异步任务的话,要及时清理,否则频繁渲染的话会造成异步任务持续增多,不会释放
解决方案
1、在componentWillUnmount时clearTimout() clearIntever()
2、在componentDidMount是clearTimout() clearIntever()之后再setTimeout() setIntever()
tips: promise无法清除掉
此外,style={{}}尽量不要使用,用className来代替
react组件对于一些异步任务的话,要及时清理,否则频繁渲染的话会造成异步任务持续增多,不会释放
解决方案
1、在componentWillUnmount时clearTimout() clearIntever()
2、在componentDidMount是clearTimout() clearIntever()之后再setTimeout() setIntever()
tips: promise无法清除掉
此外,style={{}}尽量不要使用,用className来代替
杨龙飞阅读 1.4k
alwaysVe赞 2阅读 5.9k评论 5
kovli赞 1阅读 5.4k
ipromise赞 2阅读 2.6k
若川赞 1阅读 1.6k
冴羽赞 2阅读 873
灰太狼的情与殇阅读 2k
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。