react性能优化最佳实践
- 2020 年 4 月 20 日
- 筆記
- 前端面试题~react方向
1、PureComponent 的使用场景
PureComponent 和 Component 的区别是,PureComponent 自带 shouldComponentUpdate 生命周期函数,会对传入的props进行浅比较。
PureComponent 和 immutable.js库 做结合,完美的解决react的性能问题。
2、函数式编程按需加载
React.memo()包装函数。memo方法同样是自带shouldComponentUpdate 生命周期函数,会对传入的props进行浅比较。