开发者社区 问答 正文

shouldComponentUpdate 是做什么的?(react 性能优化是哪个周期函数?)

shouldComponentUpdate 是做什么的?(react 性能优化是哪个周期函数?)

展开
收起
问问小秘 2019-11-22 14:09:35 646 分享 版权
1 条回答
写回答
取消 提交回答
  • shouldComponentUpdate 这个方法用来判断是否需要调用 render 方法重新描绘 dom。因为 dom 的描绘非常消耗性能,如果我们能在 shouldComponentUpdate 方法中能够写出更优化的 dom diff 算法,可以极大的提高性能。

    2019-11-22 14:09:47
    赞同 展开评论