reactjs 在shouldComponentUpdate中返回'true`是否与没有shouldComponentUdpate相同?

4nkexdtk  于 2023-02-04  发布在  React
关注(0)|答案(1)|浏览(98)

在React Native组件中,我添加了一个空的shouldComponentUpdate

shouldComponentUpdate(nextProps, nextState) {
        
}

我从this的答案中知道,空shouldComponentUpdate会消除所有不必要的重新呈现。如果我在shouldComponentUpdate的主体中返回true,这是否等同于删除shouldComponentUpdate

lokaqttq

lokaqttq1#

该方法的默认实现返回true,这意味着在您的情况下删除shouldComponentUpdate将导致相同的行为。
https://reactjs.org/docs/optimizing-performance.html#shouldcomponentupdate-in-action

相关问题