在React Native组件中,我添加了一个空的shouldComponentUpdate
shouldComponentUpdate
shouldComponentUpdate(nextProps, nextState) { }
我从this的答案中知道,空shouldComponentUpdate会消除所有不必要的重新呈现。如果我在shouldComponentUpdate的主体中返回true,这是否等同于删除shouldComponentUpdate?
true
lokaqttq1#
该方法的默认实现返回true,这意味着在您的情况下删除shouldComponentUpdate将导致相同的行为。https://reactjs.org/docs/optimizing-performance.html#shouldcomponentupdate-in-action
1条答案
按热度按时间lokaqttq1#
该方法的默认实现返回
true
,这意味着在您的情况下删除shouldComponentUpdate
将导致相同的行为。https://reactjs.org/docs/optimizing-performance.html#shouldcomponentupdate-in-action