Fabric: Checking getHasNewLayout in RootShadowNode

Summary:
As a comment above changed lines states, RootShadowNode is a special one because it layouts itself. In normal case some parent node layouts its children, and it also checks getHasNewLayout flag. So, in the case of RootShadowNode it has to check its own flag by itself.
That fix should save some resources and generally correct.

After the change, changing a state of some node does not cause relayout process. If dirtying is required, the component should call `dirtyLayout()` explicitly in the constructor or in `adopt` method.

Reviewed By: JoshuaGross

Differential Revision: D14472751

fbshipit-source-id: 75bf62ac28991a39e5664aa71c08bd0e64fa275b
This commit is contained in:
Valentin Shergin
2019-03-18 19:16:38 -07:00
committed by Facebook Github Bot
parent 72cd8716fd
commit 32d5c7e1f3

View File

@@ -22,7 +22,10 @@ void RootShadowNode::layout() {
// This is the rare place where shadow node must layout (set `layoutMetrics`)
// itself because there is no a parent node which usually should do it.
setLayoutMetrics(layoutMetricsFromYogaNode(yogaNode_));
if (getHasNewLayout()) {
setLayoutMetrics(layoutMetricsFromYogaNode(yogaNode_));
setHasNewLayout(false);
}
}
UnsharedRootShadowNode RootShadowNode::clone(