React.memo是一个高阶组件,本质就是一个函数。基本形式如下:

React.memo(functionl Component, areEqual)

 

React.memo与PureComponent作用一样,都是用来减少组件渲染。区别如下:

1.  React.memo针对函数式组件,PureComponent针对类组件

2. React.memo可以传入第二个参数,props比较函数,自定义比较逻辑,PureComponent只会使用默认的props浅比较

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-21
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2023-03-18
  • 2022-03-03
  • 2021-10-13
  • 2021-07-18
相关资源
相似解决方案