From f1a48e83968385fa5725972765b023293fc91b01 Mon Sep 17 00:00:00 2001 From: Krzysztof Kraszewski Date: Fri, 6 Jul 2018 14:34:19 +0200 Subject: [PATCH] fix(uimanager): handle providing incorrect view tag to UIImplementation.setChildren() --- .../react/uimanager/UIImplementation.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java index 2baee93cee9..f1fc0923c37 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java @@ -478,12 +478,23 @@ public void setChildren( ReadableArray childrenTags) { ReactShadowNode cssNodeToManage = mShadowNodeRegistry.getNode(viewTag); + if (cssNodeToManage == null) { + FLog.w( + ReactConstants.TAG, + "Tried to add children to non-existent parent with tag " + viewTag + ); + return; + } for (int i = 0; i < childrenTags.size(); i++) { - ReactShadowNode cssNodeToAdd = mShadowNodeRegistry.getNode(childrenTags.getInt(i)); + int childTag = childrenTags.getInt(i); + ReactShadowNode cssNodeToAdd = mShadowNodeRegistry.getNode(childTag); if (cssNodeToAdd == null) { - throw new IllegalViewOperationException("Trying to add unknown view tag: " - + childrenTags.getInt(i)); + FLog.w( + ReactConstants.TAG, + "Tried to add a non-existent child with tag " + childTag + " to parent with tag " + viewTag + ); + return; } cssNodeToManage.addChildAt(cssNodeToAdd, i); }