diff --git a/ReactAndroid/src/main/java/com/facebook/yoga/YogaNodeJNIBase.java b/ReactAndroid/src/main/java/com/facebook/yoga/YogaNodeJNIBase.java index 7ab391cce51cf7..6b3dcd267e1a4e 100644 --- a/ReactAndroid/src/main/java/com/facebook/yoga/YogaNodeJNIBase.java +++ b/ReactAndroid/src/main/java/com/facebook/yoga/YogaNodeJNIBase.java @@ -83,6 +83,9 @@ public YogaNodeJNIBase getChildAt(int i) { } public void addChildAt(YogaNode c, int i) { + if (!(c instanceof YogaNodeJNIBase)) { + return; + } YogaNodeJNIBase child = (YogaNodeJNIBase) c; if (child.mOwner != null) { throw new IllegalStateException("Child already has a parent, it must be removed first."); @@ -105,6 +108,9 @@ public boolean isReferenceBaseline() { } public void swapChildAt(YogaNode newChild, int position) { + if (!(newChild instanceof YogaNodeJNIBase)) { + return; + } YogaNodeJNIBase child = (YogaNodeJNIBase) newChild; mChildren.remove(position); mChildren.add(position, child); @@ -223,6 +229,9 @@ public boolean isDirty() { @Override public void copyStyle(YogaNode srcNode) { + if (!(srcNode instanceof YogaNodeJNIBase)) { + return; + } YogaNative.jni_YGNodeCopyStyleJNI(mNativePointer, ((YogaNodeJNIBase) srcNode).mNativePointer); }