首先我们使用react组件会配合connect来连接store获取state,那么只要store中的state发生改变组件就会重新渲染,所以性能不高,一般我们可以使用shouldComponentUpdate()来判断,但react提供了PureComponent组件,当我们把Component替换成PureComponent的时候会自动帮我们优化组件避免不必要的渲染,注意:前提是使用immutable来管理数据,不然会出现一些问题。

import React, { PureComponent } from 'react';
class App extends PureComponent{
    render(){
        return(<div></div>);
    }
}
export default App;

 

相关文章:

  • 2021-06-15
  • 2021-10-21
  • 2021-12-30
  • 2021-12-02
  • 2021-06-20
  • 2021-08-18
猜你喜欢
  • 2021-07-18
  • 2022-02-07
  • 2021-05-11
  • 2022-12-23
  • 2021-10-19
  • 2022-12-23
相关资源
相似解决方案