diff --git a/packages/react-native/ReactCommon/react/renderer/core/ShadowNode.cpp b/packages/react-native/ReactCommon/react/renderer/core/ShadowNode.cpp index 196391bd8c7301..a14b700a0b2e22 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/ShadowNode.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/ShadowNode.cpp @@ -310,14 +310,19 @@ void ShadowNode::setRuntimeShadowNodeReference( runtimeShadowNodeReference_ = runtimeShadowNodeReference; } +void ShadowNode::updateRuntimeShadowNodeReference( + const Shared& destinationShadowNode) const { + if (auto reference = runtimeShadowNodeReference_.lock()) { + reference->shadowNode = destinationShadowNode; + } +} + void ShadowNode::transferRuntimeShadowNodeReference( const Shared& destinationShadowNode) const { destinationShadowNode->runtimeShadowNodeReference_ = runtimeShadowNodeReference_; - if (auto reference = runtimeShadowNodeReference_.lock()) { - reference->shadowNode = destinationShadowNode; - } + updateRuntimeShadowNodeReference(destinationShadowNode); } void ShadowNode::transferRuntimeShadowNodeReference( diff --git a/packages/react-native/ReactCommon/react/renderer/core/ShadowNode.h b/packages/react-native/ReactCommon/react/renderer/core/ShadowNode.h index 7a3ad9cbc1b8b3..ae648988875ade 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/ShadowNode.h +++ b/packages/react-native/ReactCommon/react/renderer/core/ShadowNode.h @@ -187,6 +187,12 @@ class ShadowNode : public Sealable, void setRuntimeShadowNodeReference(const std::shared_ptr& runtimeShadowNodeReference) const; + /* + * Update the runtime reference to point to the provided shadow node. + */ + void updateRuntimeShadowNodeReference( + const Shared& destinationShadowNode) const; + /* * Transfer the runtime reference to this `ShadowNode` to a new instance, * updating the reference to point to the new `ShadowNode` referencing it.