mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fabric: SafeAreaView does always not dirty Yoga node during cloning anymore
Summary: Setting `padding` for Yoga node dirties it. In the previous implementation, we did it for all newly cloned nodes. Now we do it only if State actually changes. This is important because usually, SafeAreaView is a container node; that means that if some descendant of SafeAreaView changes its state, the recloning of all nodes down to root node will cause dirtying SafeAreaView and cause relayout if the whole subtree. E.g., if we put ScrollView inside SafeAreaView without the fix, onScroll events will cause Yoga relayout (because ScrollView updates own state on debounced onScroll event). Changelog: [Internal] Fabric-specific internal change. Reviewed By: JoshuaGross Differential Revision: D18987158 fbshipit-source-id: a3130c607c37e54ce813113222cd4a3872c58b6a
This commit is contained in:
committed by
Facebook Github Bot
parent
e020576b34
commit
ebdce9b3b0
@@ -35,7 +35,10 @@ class SafeAreaViewComponentDescriptor final
|
||||
shadowNode->getState());
|
||||
auto stateData = state->getData();
|
||||
|
||||
layoutableShadowNode->setPadding(stateData.padding);
|
||||
if (safeAreaViewShadowNode->alreadyAppliedPadding != stateData.padding) {
|
||||
safeAreaViewShadowNode->alreadyAppliedPadding = stateData.padding;
|
||||
layoutableShadowNode->setPadding(stateData.padding);
|
||||
}
|
||||
|
||||
ConcreteComponentDescriptor::adopt(shadowNode);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,9 @@ class SafeAreaViewShadowNode final : public ConcreteViewShadowNode<
|
||||
ViewEventEmitter,
|
||||
SafeAreaViewState> {
|
||||
using ConcreteViewShadowNode::ConcreteViewShadowNode;
|
||||
|
||||
public:
|
||||
EdgeInsets alreadyAppliedPadding{};
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
|
||||
Reference in New Issue
Block a user