From 45472fe40000f805ed498b5356f791cb09b6a482 Mon Sep 17 00:00:00 2001 From: Ahmed El-Helw Date: Thu, 3 Mar 2016 13:39:38 -0800 Subject: [PATCH] Fix detaching dropped views in Nodes Summary: Groups had a crash when running with React with Nodes when returning from a search screen. This was due to the fact that the node representing a ShimmerFrameLayout was being dropped, and then later we were trying to detach it. Since the view was already dropped, we shouldn't try to detach it since it's already dropped and removed from the view hierarchy. Reviewed By: sriramramani Differential Revision: D3004541 --- .../main/java/com/facebook/react/flat/StateBuilder.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/StateBuilder.java b/ReactAndroid/src/main/java/com/facebook/react/flat/StateBuilder.java index b29e5e75d..a3e74df7b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/StateBuilder.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/StateBuilder.java @@ -109,6 +109,13 @@ import com.facebook.react.uimanager.events.EventDispatcher; mOnLayoutEvents.clear(); if (!mViewsToDrop.isEmpty()) { + for (int i = 0, mViewsToDropSize = mViewsToDrop.size(); i < mViewsToDropSize; i++) { + // set parent tag to -1 to avoid trying to detach this view + FlatShadowNode shadowNode = mViewsToDrop.get(i); + if (shadowNode.mountsToView()) { + shadowNode.setNativeParentTag(-1); + } + } mOperationsQueue.enqueueDropViews(collectViewTags(mViewsToDrop)); mViewsToDrop.clear(); }