diff --git a/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNode.java b/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNode.java index ae9f07b92..2795d8ce4 100644 --- a/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNode.java +++ b/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNode.java @@ -649,5 +649,6 @@ public class CSSNode implements CSSNodeAPI { layout.resetResult(); lineIndex = 0; mLayoutState = LayoutState.DIRTY; + mMeasureFunction = null; } } diff --git a/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNodeJNI.java b/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNodeJNI.java index 356bddccc..3f7704647 100644 --- a/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNodeJNI.java +++ b/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNodeJNI.java @@ -56,6 +56,9 @@ public class CSSNodeJNI implements CSSNodeAPI { @Override public void reset() { assertNativeInstance(); + if (mParent != null || (mChildren != null && mChildren.size() > 0)) { + throw new IllegalStateException("You should not reset an attached CSSNode"); + } jni_CSSNodeFree(mNativePointer); mNativePointer = 0; @@ -78,6 +81,9 @@ public class CSSNodeJNI implements CSSNodeAPI { @Override public void addChildAt(CSSNodeJNI child, int i) { assertNativeInstance(); + if (child.mParent != null) { + throw new IllegalStateException("Child already has a parent, it must be removed first."); + } mChildren.add(i, child); child.mParent = this;