最佳答案
随着 React 中 钩子的引入,现在主要的困惑是什么时候使用带钩子和类组件的函数组件,因为借助钩子,即使在函数组件中也可以得到 state
和部分 lifecycle hooks
。我有以下问题
例如,带钩子的函数组件不能像类组件那样帮助 perf。它们不能跳过重新呈现,因为它们没有实现 shouldComponentUpdate
。还有别的原因吗?
先谢谢你。