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:
Valentin Shergin
2019-12-15 18:49:31 -08:00
committed by Facebook Github Bot
parent e020576b34
commit ebdce9b3b0
2 changed files with 7 additions and 1 deletions
@@ -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