2022-11-8 性能优化SCU。PureComponent和memo()

242 阅读1分钟

image.png

image.png

image.png

image.png

image.png

注:这里通过memo()将Profile组件包裹,返回一个新的Profile组件,然后我们导出新的组件即可。

memo()帮助我们判断其父组件传来的props是否做了改变,如果改变才需要重新调用Profile的render,如果没有改变则不需要重新调用render.

memo()的功能类似于class组件的PureComponent

这两个东西在开发过程中需要经常用到(如果没有这两个东西肯定是新手开发,属于必须要用到的东西),能够极大的提高性能优化

image.png

image.png