react性能优化最佳实践

1、PureComponent 的使用场景
PureComponent 和 Component 的区别是,PureComponent 自带 shouldComponentUpdate 生命周期函数,会对传入的props进行浅比较。
PureComponent 和 immutable.js库 做结合,完美的解决react的性能问题。
 
2、函数式编程按需加载
React.memo()包装函数。memo方法同样是自带shouldComponentUpdate 生命周期函数,会对传入的props进行浅比较。

猜你喜欢

转载自www.cnblogs.com/zerodang/p/12738701.html