Create app with a custom native module that calls recreateReactContextInBackground.
To see it more clearly, it adds some code to the app that displays the timestamp on mount (so it can be seen that the old view isn't removed when the timestamp doesn't change):
New Version
0.73.0-rc.5
Old Version
0.72.5
Build Target(s)
Android in Release Build Variant
Output of
react-native info
Issue and Reproduction Steps
Issue: calling
recreateReactContextInBackground
on theReactInstanceManager
instance no longer removes the old root view.Suspected blame rev: https://github.com/facebook/react-native/pull/37004
Previously,
tearDownReactContext
would callclearReactRoot
, but now it callsdetachRootViewFromInstance
. IndetachRootViewFromInstance
, only the view ID is reset: https://github.com/javache/react-native/blob/a63613ca7bffd54211985224a61300d5de0f5640/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java#L1295 as opposed toclearReactRoot
which also removes the views from the root view group: https://github.com/javache/react-native/blob/a63613ca7bffd54211985224a61300d5de0f5640/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java#L847This occurs in both fabric and non-fabric.
Repro: https://github.com/wschurman/rn-reload-repro
The repro repo does the following:
recreateReactContextInBackground
.