From 6aa52f2684301ee2fd5afa192c6790b426cf0d6a Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Thu, 26 Apr 2018 17:51:41 -0700 Subject: [PATCH] Fabric: Using a proper Component Descriptor for node cloning Summary: To clone a ShadowNode we must use node's ComponentDescriptot, not parent node's one. Reviewed By: mdvacca Differential Revision: D7738583 fbshipit-source-id: 83656f9a761530cdaedf65663ae28b3119af75f5 --- .../core/componentdescriptor/ConcreteComponentDescriptor.h | 1 + ReactCommon/fabric/uimanager/FabricUIManager.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ReactCommon/fabric/core/componentdescriptor/ConcreteComponentDescriptor.h b/ReactCommon/fabric/core/componentdescriptor/ConcreteComponentDescriptor.h index 2e2ee37fd..11b82b32f 100644 --- a/ReactCommon/fabric/core/componentdescriptor/ConcreteComponentDescriptor.h +++ b/ReactCommon/fabric/core/componentdescriptor/ConcreteComponentDescriptor.h @@ -81,6 +81,7 @@ private: ShadowNodeCloneFunction getCloneFunction() const { if (!cloneFunction_) { cloneFunction_ = [this](const SharedShadowNode &shadowNode, const SharedProps &props, const SharedShadowNodeSharedList &children) { + assert(std::dynamic_pointer_cast(shadowNode)); return this->cloneShadowNode(shadowNode, props, children); }; } diff --git a/ReactCommon/fabric/uimanager/FabricUIManager.cpp b/ReactCommon/fabric/uimanager/FabricUIManager.cpp index dc73808f4..3b8786b29 100644 --- a/ReactCommon/fabric/uimanager/FabricUIManager.cpp +++ b/ReactCommon/fabric/uimanager/FabricUIManager.cpp @@ -151,7 +151,8 @@ void FabricUIManager::appendChild(const SharedShadowNode &parentShadowNode, cons // TODO: Remove this after we move this to JS side. if (childShadowNode->getSealed()) { - auto clonedChildShadowNode = componentDescriptor->cloneShadowNode(childShadowNode); + auto childComponentDescriptor = (*componentDescriptorRegistry_)[childShadowNode]; + auto clonedChildShadowNode = childComponentDescriptor->cloneShadowNode(childShadowNode); auto nonConstClonedChildShadowNode = std::const_pointer_cast(clonedChildShadowNode); nonConstClonedChildShadowNode->shallowSourceNode(); componentDescriptor->appendChild(parentShadowNode, clonedChildShadowNode);