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