Mutate shared ReactShadowNode during Fabric.appendChild

Reviewed By: shergin

Differential Revision: D7495539

fbshipit-source-id: 2b2b06d3d4f02a00b01c7ed27d47b61787ea922f
This commit is contained in:
David Vacca 2018-04-06 15:01:13 -07:00 committed by Facebook Github Bot
parent 9736ddc061
commit e21bbee586
1 changed files with 6 additions and 0 deletions

View File

@ -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);