From e21bbee5862eaf08c8f198fa18a32350f5caabbc Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 6 Apr 2018 15:01:13 -0700 Subject: [PATCH] Mutate shared ReactShadowNode during Fabric.appendChild Reviewed By: shergin Differential Revision: D7495539 fbshipit-source-id: 2b2b06d3d4f02a00b01c7ed27d47b61787ea922f --- .../java/com/facebook/react/fabric/FabricUIManager.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index 2cadd153c..52519e9d3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -216,6 +216,12 @@ public class FabricUIManager implements UIManager { Log.d(TAG, "appendChild \n\tparent: " + parent + "\n\tchild: " + child); } try { + // If the child to append is shared with another tree (child.getParent() != null), + // then we add a mutation of it. In the future this will be performed by FabricJS / Fiber. + //TODO: T27926878 avoid cloning shared child + if (child.getParent() != null) { + child = child.mutableCopy(); + } parent.addChildAt(child, parent.getChildCount()); } catch (Throwable t) { handleException(parent, t);