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 1a64b95b16a..f7ee626491f 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -211,6 +212,11 @@ void YogaLayoutableShadowNode::adoptYogaChild(size_t index) { // TODO: At this point, React has wrong reference to the node. (T138668036) auto clonedChildNode = childNode.clone({}); + if (ReactNativeFeatureFlags:: + useRuntimeShadowNodeReferenceUpdateOnLayout()) { + childNode.transferRuntimeShadowNodeReference(clonedChildNode); + } + // Replace the child node with a newly cloned one in the children list. replaceChild(childNode, clonedChildNode, index); } @@ -518,6 +524,10 @@ YogaLayoutableShadowNode& YogaLayoutableShadowNode::cloneChildInPlace( ShadowNodeFragment::childrenPlaceholder(), childNode.getState()}); + if (ReactNativeFeatureFlags::useRuntimeShadowNodeReferenceUpdateOnLayout()) { + childNode.transferRuntimeShadowNodeReference(clonedChildNode); + } + replaceChild(childNode, clonedChildNode, layoutableChildIndex); return static_cast(*clonedChildNode); }