In this lesson, you will learn how to use PureComponent in React to reduce the number of times your component re-renders.

This works because PureComponent implements a shallow comparison for us by default in shouldComponentUpdate() , saving us time and reducing the complexity of our components. Its important to note that the comparison is shallow, meaning that if you are updating an object with nested values the component will not re-render as React has not noticed a change.

The same, if you pass a prop as a function reference, it will not cause re-render, but is you pass a anonymous arrow function which means it will create a new function every time, then it will cuase re-render.

 handleChange = e => {
const { name, value } = e.target;
this.setState({ [name]: value });
}; // pass a function
<Counter onChange={this.handleChange} /> // vs pass a arrow function
<Counter onChange={() => console.log('this will cause re-render')} />

最新文章

  1. LoadRunner,一个简单的例子
  2. c语言实现二维数组排序,一个4*5的数组,要求每行都进行升序排列,并求出每行的平均值。
  3. 【Linux高频命令专题(15)】more
  4. Visual Studio 2008快捷键
  5. JavaScript引用是如何工作的
  6. 初识Java-IO流
  7. Windows Azure Virtual Machine (34) Azure VM挂载WebDAV
  8. FusionCharts封装-单系列图
  9. 关于leal和mov
  10. Python 汉诺塔
  11. SpringMVC Controller 返回值几种类型
  12. C#数组维数及不同维数中元素个数的获取
  13. liunx 安装maven
  14. Linux交叉编译工具链和模块编译
  15. 在IIS服务上发布网站
  16. 后序线索化二叉树(Java版)
  17. PXE Centos7和Centos6
  18. ssh -X前设置DISPLAY=localhost:0
  19. git多站点多用户情况下SSH配置
  20. bzoj5000 OI树

热门文章

  1. sklearn之SVC
  2. PRJ0003 : Error spawning &#39;midl.exe&#39;
  3. java分段加载数据,循环和递归两种方式
  4. shell $() vs ${}
  5. 【2018 CCPC网络赛】1004 - 费马大定理&amp;数学
  6. C指针与数组之间的细节
  7. python 装饰器模拟京东登陆
  8. 「LibreOJ β Round #3」绯色 IOI(抵达)
  9. C++实现链队类——合肥工业大学数据结构实验5:链式队列
  10. iframe in ipad safari