From 754d2848a4766355534c2c3317c0ca3628048bef Mon Sep 17 00:00:00 2001 From: Ahmed El-Helw Date: Tue, 14 Jun 2016 12:31:59 -0700 Subject: [PATCH] Fix dispatchViewManagerCommand ordering for Nodes Summary: The dispatchViewManager command should, according to the spec, only be executed after children are added. On Nodes, however, due to the fact that the Views in question may not have been created until the call to the command occurred, the dispatchViewManagerCommand may occur too early. Consequently, ensure that we apply any state updates to the Node represented by that reactTag before we enqueue the view manager command (this will ensure that views are properly added to the parent, etc before sending the command). Reviewed By: astreet Differential Revision: D3428855 --- .../java/com/facebook/react/flat/FlatUIImplementation.java | 4 ++++ 1 file changed, 4 insertions(+) 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 99a4b7e1f..8aa07d036 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java @@ -244,6 +244,10 @@ public class FlatUIImplementation extends UIImplementation { @Override public void dispatchViewManagerCommand(int reactTag, int commandId, ReadableArray commandArgs) { 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). + mStateBuilder.applyUpdates((FlatShadowNode) resolveShadowNode(reactTag)); super.dispatchViewManagerCommand(reactTag, commandId, commandArgs); }