Skip to content

Commit

Permalink
Make new nodes dirty by default (#44010)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #44010

X-link: facebook/yoga#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
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Apr 11, 2024
1 parent 3098613 commit 44d59ea
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/ReactCommon/yoga/yoga/node/Node.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>() = NodeType::Default;
void* context_ = nullptr;
Expand Down

0 comments on commit 44d59ea

Please sign in to comment.