From 44d59ea6f9a1705487314e33de52f7056651ba25 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Wed, 10 Apr 2024 22:15:25 -0700 Subject: [PATCH] Make new nodes dirty by default (#44010) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44010 X-link: https://github.com/facebook/yoga/pull/1641 Yoga has quirk where newly constructed nodes are clean, which isn't really correct. Normally never shows in in real code because setting a style or children will dirty. Fabric doesn't use the public APIs that do this dirtying, so it ends up getting creative instead. We should fix so that newly constructed nodes are dirty. Copy-constructed Nodes (also only a Fabric thing, will retain original dirty flag. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D55855328 fbshipit-source-id: be49efaf8ac29351f8e5ec509bd9912546944332 --- .../renderer/components/view/YogaLayoutableShadowNode.cpp | 4 ---- packages/react-native/ReactCommon/yoga/yoga/node/Node.h | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp b/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp index 513d93e88c1..89cc5e6b0a0 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp @@ -72,10 +72,6 @@ YogaLayoutableShadowNode::YogaLayoutableShadowNode( yogaNode_(&initializeYogaConfig(yogaConfig_)) { yogaNode_.setContext(this); - // Newly created node must be `dirty` just because it is new. - // This is not a default for `yoga::Node`. - yogaNode_.setDirty(true); - if (getTraits().check(ShadowNodeTraits::Trait::MeasurableYogaNode)) { react_native_assert( getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode)); diff --git a/packages/react-native/ReactCommon/yoga/yoga/node/Node.h b/packages/react-native/ReactCommon/yoga/yoga/node/Node.h index ec28f2db91a..8f5ee591cc5 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/node/Node.h +++ b/packages/react-native/ReactCommon/yoga/yoga/node/Node.h @@ -271,7 +271,7 @@ class YG_EXPORT Node : public ::YGNode { bool hasNewLayout_ : 1 = true; bool isReferenceBaseline_ : 1 = false; - bool isDirty_ : 1 = false; + bool isDirty_ : 1 = true; bool alwaysFormsContainingBlock_ : 1 = false; NodeType nodeType_ : bitCount() = NodeType::Default; void* context_ = nullptr;