diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp index 6e909a73902b..e5ced223b613 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp @@ -268,7 +268,12 @@ ShadowNode::Shared UIManager::getNewestCloneOfShadowNode( shadowNode.getSurfaceId(), [&](const ShadowTree& shadowTree) { ancestorShadowNode = shadowTree.getCurrentRevision().rootShadowNode; }); + return getNewestCloneOfShadowNodeFromAncestor(shadowNode, ancestorShadowNode); +} +ShadowNode::Shared UIManager::getNewestCloneOfShadowNodeFromAncestor( + const ShadowNode& shadowNode, + const ShadowNode::Shared& ancestorShadowNode) const { if (!ancestorShadowNode) { return nullptr; } @@ -427,6 +432,8 @@ void UIManager::setNativeProps_DEPRECATED( family.getSurfaceId(), [&](const ShadowTree& shadowTree) { // The lambda passed to `commit` may be executed multiple times. // We need to create fresh copy of the `RawProps` object each time. + auto ancestorShadowNode = + shadowTree.getCurrentRevision().rootShadowNode; shadowTree.commit( [&](RootShadowNode const& oldRootShadowNode) { auto rootNode = oldRootShadowNode.cloneTree( @@ -438,7 +445,9 @@ void UIManager::setNativeProps_DEPRECATED( family.getSurfaceId(), *contextContainer_.get()}; auto props = componentDescriptor.cloneProps( propsParserContext, - getNewestCloneOfShadowNode(*shadowNode)->getProps(), + getNewestCloneOfShadowNodeFromAncestor( + *shadowNode, ancestorShadowNode) + ->getProps(), RawProps(rawProps)); return oldShadowNode.clone({/* .props = */ props}); diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.h b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.h index d32dca94b190..e0dc7e98a485 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.h +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.h @@ -218,6 +218,10 @@ class UIManager final : public ShadowTreeDelegate { const jsi::Value& successCallback, const jsi::Value& failureCallback) const; + ShadowNode::Shared getNewestCloneOfShadowNodeFromAncestor( + const ShadowNode& shadowNode, + const ShadowNode::Shared& ancestorShadowNode) const; + SharedComponentDescriptorRegistry componentDescriptorRegistry_; UIManagerDelegate* delegate_{}; UIManagerAnimationDelegate* animationDelegate_{nullptr};