react组件对于一些异步任务的话,要及时清理,否则频繁渲染的话会造成异步任务持续增多,不会释放
解决方案
1、在componentWillUnmount时clearTimout() clearIntever()
2、在componentDidMount是clearTimout() clearIntever()之后再setTimeout() setIntever()
tips: promise无法清除掉
此外,style={{}}尽量不要使用,用className来代替
原文地址:https://segmentfault.com/a/1190000022528728