Added an Assertion that addRoot is called before completeRoot

Reviewed By: mdvacca

Differential Revision: D7127321

fbshipit-source-id: a8215fda0d854471bed9aa5476141dfffc4dc11c
This commit is contained in:
Andrew Chen (Eng) 2018-03-01 16:51:48 -08:00 committed by Facebook Github Bot
parent 22990c3ce7
commit 6404529b76
1 changed files with 15 additions and 14 deletions

View File

@ -180,7 +180,7 @@ public class FabricUIManagerModule implements UIManager {
public void appendChild(ReactShadowNode parent, ReactShadowNode child) { public void appendChild(ReactShadowNode parent, ReactShadowNode child) {
try { try {
parent.addChildAt(child, parent.getChildCount()); parent.addChildAt(child, parent.getChildCount());
setChildren(parent.getReactTag(), child.getReactTag()); addChild(parent.getReactTag(), child.getReactTag());
} catch (Exception e) { } catch (Exception e) {
handleException(parent.getThemedContext(), e); handleException(parent.getThemedContext(), e);
} }
@ -203,25 +203,26 @@ public class FabricUIManagerModule implements UIManager {
public void completeRoot(int rootTag, List<ReactShadowNode> childList) { public void completeRoot(int rootTag, List<ReactShadowNode> childList) {
try { try {
if (!childList.isEmpty()) { ReactShadowNode rootNode = getRootNode(rootTag);
ReactShadowNode rootNode = getRootNode(rootTag); Assertions.assertNotNull(
for (int i = 0; i < childList.size(); i++) { rootNode,
ReactShadowNode child = childList.get(i); "Root view with tag " + rootTag + " must be added before completeRoot is called");
rootNode.addChildAt(child, i); for (int i = 0; i < childList.size(); i++) {
setChildren(rootTag, child.getReactTag()); ReactShadowNode child = childList.get(i);
} rootNode.addChildAt(child, i);
addChild(rootTag, child.getReactTag());
calculateRootLayout(rootNode);
applyUpdatesRecursive(rootNode, 0, 0);
mUIViewOperationQueue
.dispatchViewUpdates(1, System.currentTimeMillis(), System.currentTimeMillis());
} }
calculateRootLayout(rootNode);
applyUpdatesRecursive(rootNode, 0, 0);
mUIViewOperationQueue
.dispatchViewUpdates(1, System.currentTimeMillis(), System.currentTimeMillis());
} catch (Exception e) { } catch (Exception e) {
handleException(rootTag, e); handleException(rootTag, e);
} }
} }
private void setChildren(int parent, int child) { private void addChild(int parent, int child) {
JavaOnlyArray childrenTags = new JavaOnlyArray(); JavaOnlyArray childrenTags = new JavaOnlyArray();
childrenTags.pushInt(child); childrenTags.pushInt(child);
mUIViewOperationQueue.enqueueSetChildren( mUIViewOperationQueue.enqueueSetChildren(