从Component到PureComponent

What is the PureComponent ?

 PureComponent   是 React15.3 版本新增的类,顾名思义, PureComponent   是由  Pure (纯)+  Component (组件),意思就是纯组件。

Why use the PureComponent ?

 PureComponent  取代了其前身  PureRenderMixin ,是优化  React  应用程序性能的重要方法之一。

 PureComponent  使用十分简单,只要把组件代码中继承的  Component  替换成 PureComponent  即可。

 PureComponent  之所有能提高性能,是因为在  PureComponent  类中默认实现  ShouldComponentUpdate  函数,从而减少了不必要的  render  更新界面的操作,同时也帮我们节省了实现  ShouldComponentUpdate  函数的代码。

猜你喜欢

转载自www.cnblogs.com/youloveme/p/10105928.html