Skip to content

Commit 96939f1

Browse files
Nick Lefeverfacebook-github-bot
authored andcommitted
Use source shadow node state on clone (#50773)
Summary: Pull Request resolved: #50773 With shadow node syncing enabled by default, whenever a shadow node has to be cloned, we can be guaranteed that the state on the shadow node will be the most recent state in most cases. This change fixes state updates being ignored when cloning YogaLayoutableShadowNodes from a commit hook. Since the most recent state gets updated post commit, any clone reading the most recent state might miss state changes done within the commit. Changelog: [Internal] Reviewed By: rshest, cipolleschi Differential Revision: D72315898 fbshipit-source-id: 5e14d03681dd1cc5686a649caa2e8c3685042cfa
1 parent b962646 commit 96939f1

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

packages/react-native/ReactCommon/react/renderer/core/ShadowNode.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ ShadowNode::ShadowNode(
112112
fragment.children ? fragment.children : sourceShadowNode.children_),
113113
state_(
114114
fragment.state ? fragment.state
115-
: sourceShadowNode.getMostRecentState()),
115+
: (ReactNativeFeatureFlags::useShadowNodeStateOnClone()
116+
? sourceShadowNode.state_
117+
: sourceShadowNode.getMostRecentState())),
116118
orderIndex_(sourceShadowNode.orderIndex_),
117119
family_(sourceShadowNode.family_),
118120
traits_(sourceShadowNode.traits_) {

0 commit comments

Comments
 (0)