From 32d5c7e1f3f644ee17588d4141d8fe8b7d1f1f51 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Mon, 18 Mar 2019 19:16:38 -0700 Subject: [PATCH] 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 --- ReactCommon/fabric/components/root/RootShadowNode.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ReactCommon/fabric/components/root/RootShadowNode.cpp b/ReactCommon/fabric/components/root/RootShadowNode.cpp index 85a11ea02..2037f0191 100644 --- a/ReactCommon/fabric/components/root/RootShadowNode.cpp +++ b/ReactCommon/fabric/components/root/RootShadowNode.cpp @@ -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(