diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java index df6cbaff2..6580d36bf 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java @@ -224,10 +224,14 @@ public class FlatUIImplementation extends UIImplementation { callback); } - private void ensureMountsToViewAndBackingViewIsCreated(int reactTag) { + private boolean ensureMountsToViewAndBackingViewIsCreated(int reactTag) { FlatShadowNode node = (FlatShadowNode) resolveShadowNode(reactTag); + if (node.isBackingViewCreated()) { + return false; + } node.forceMountToView(); mStateBuilder.ensureBackingViewIsCreated(node); + return true; } @Override @@ -249,8 +253,15 @@ public class FlatUIImplementation extends UIImplementation { @Override public void dispatchViewManagerCommand(int reactTag, int commandId, ReadableArray commandArgs) { - ensureMountsToViewAndBackingViewIsCreated(reactTag); - mStateBuilder.applyUpdates((FlatShadowNode) resolveShadowNode(reactTag)); + if (ensureMountsToViewAndBackingViewIsCreated(reactTag)) { + // need to make sure any ui operations (UpdateViewGroup, for example, etc) have already + // happened before we actually dispatch the view manager command (since otherwise, the command + // may go to an empty shell parent without its children, which is against the specs). note + // that we only want to applyUpdates if the view has not yet been created so that it does + // get created (otherwise, we may end up changing the View's position when we're not supposed + // to, for example). + mStateBuilder.applyUpdates((FlatShadowNode) resolveShadowNode(reactTag)); + } super.dispatchViewManagerCommand(reactTag, commandId, commandArgs); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatViewGroup.java b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatViewGroup.java index 419d54699..1cc606b22 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatViewGroup.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatViewGroup.java @@ -164,8 +164,6 @@ import com.facebook.react.views.view.ReactClippingViewGroupHelper; @Override public void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - if (mRemoveClippedSubviews) { for (DrawCommand drawCommand : mDrawCommands) { if (drawCommand instanceof DrawView) {