Skip to content

Commit 252874b

Browse files
Nick Lefeveruffoltzl
Nick Lefever
authored and
uffoltzl
committed
Use source shadow node state on clone (facebook#50773)
Summary: Pull Request resolved: facebook#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 10c60cc commit 252874b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: packages/react-native/ReactCommon/react/renderer/core/ShadowNode.cpp

+3-1
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)