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
This commit is contained in:
Ahmed El-Helw
2016-06-14 12:31:59 -07:00
parent 65f4988ddf
commit 754d2848a4

View File

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