From 7b82df287d36e39073d29e3ae3adbe82cf424055 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Sat, 19 Sep 2020 02:31:08 -0700 Subject: [PATCH] Notify ViewManagers when a View is deleted Summary: In a previous recent diff we changed Android's Delete mount instruction to *not* recursively delete the tree. This is fine, but because of that, we stopped calling `onDropViewInstance` when views are normally deleted. Bring back that behaviour. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D23801666 fbshipit-source-id: 54e6b52ab51fff2a45102e37077fe41081499888 --- .../facebook/react/fabric/mounting/MountingManager.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java index 41cf97c71fb..6ff40bda0ff 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java @@ -399,7 +399,7 @@ public class MountingManager { } throw new IllegalStateException( - "Tried to delete view [" + "Tried to remove view [" + tag + "] of parent [" + parentTag @@ -586,6 +586,12 @@ public class MountingManager { // Additionally, as documented in `dropView`, we cannot always trust a // view's children to be up-to-date. mTagToViewState.remove(reactTag); + + // For non-root views we notify viewmanager with {@link ViewManager#onDropInstance} + ViewManager viewManager = viewState.mViewManager; + if (!viewState.mIsRoot && viewManager != null) { + viewManager.onDropViewInstance(viewState.mView); + } } @UiThread