mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix android root view group removal during instance re-creation (#41678)
Summary: This is my proposed solution to https://github.com/facebook/react-native/issues/41677. Fixes https://github.com/facebook/react-native/issues/41677. ## Changelog: [ANDROID] [FIXED] - Fix android root view group removal during instance re-creation Pull Request resolved: https://github.com/facebook/react-native/pull/41678 Test Plan: Both with fabric enabled and disabled (new architecture): 1. Clone repro repo: https://github.com/wschurman/rn-reload-repro 2. Build and run on android (I use android studio) 3. Click reload button, see timestamp doesn't change (indicating that the view is not removed) 4. Apply this PR as a patch. 5. Re-build and run. 6. Click reload button, see view is correctly disposed of and the new view is set. Reviewed By: cortinico Differential Revision: D51658524 Pulled By: javache fbshipit-source-id: d9a026cde677ad1ec113230bc31bd9297bca8bfc
This commit is contained in:
committed by
Facebook GitHub Bot
parent
dc95568375
commit
bb075d785d
+1
-4
@@ -1296,14 +1296,12 @@ public class ReactInstanceManager {
|
||||
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 @@ public class ReactInstanceManager {
|
||||
.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)
|
||||
|
||||
Reference in New Issue
Block a user