diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index be0ca24b62f2ad..a1801d5627c933 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -1296,14 +1296,12 @@ private void detachRootViewFromInstance(ReactRoot reactRoot, ReactContext reactC uiManager.stopSurface(surfaceId); } else { FLog.w(ReactConstants.TAG, "Failed to stop surface, UIManager has already gone away"); - reactRoot.getRootViewGroup().removeAllViews(); } } else { ReactSoftExceptionLogger.logSoftException( TAG, new RuntimeException( "detachRootViewFromInstance called with ReactRootView with invalid id")); - reactRoot.getRootViewGroup().removeAllViews(); } } else { reactContext @@ -1312,8 +1310,7 @@ private void detachRootViewFromInstance(ReactRoot reactRoot, ReactContext reactC .unmountApplicationComponentAtRootTag(reactRoot.getRootViewTag()); } - // The view is no longer attached, so mark it as such by resetting its ID. - reactRoot.getRootViewGroup().setId(View.NO_ID); + clearReactRoot(reactRoot); } @ThreadConfined(UI)