@@ -51,21 +51,25 @@ class NativeReloadHandler(val context: ReactApplicationContext) {
5151
5252 private fun handleJSBundleLoading () {
5353 val bundle = (context.applicationContext as MendixApplication ).jsBundleFile
54- val instanceManager =
55- (context.applicationContext as ReactApplication ).reactNativeHost.reactInstanceManager
5654
5755 val latestJSBundleLoader = if (bundle != null ) {
5856 getAssetLoader(bundle)
5957 } else {
6058 getAssetLoader(" assets://index.android.bundle" )
61- }
59+ } ? : return
6260
63- ReflectionUtils .setField(instanceManager, " mBundleLoader" , latestJSBundleLoader)
64- ReflectionUtils .setField(
65- instanceManager,
66- " mUseDeveloperSupport" ,
67- (context.applicationContext as MendixApplication ).useDeveloperSupport
68- )
61+ // New Architecture (Bridgeless): on reload, ReactHostImpl loads the bundle from
62+ // its ReactHostDelegate.jsBundleLoader, which is captured once at host-creation
63+ // time and never re-consults getJSBundleFile(). Without updating it here, a warm
64+ // reload keeps loading the original bundle, so a freshly-deployed OTA bundle is
65+ // never picked up and the app loops: download -> deploy -> reload -> same bundle.
66+ val reactHost = (context.applicationContext as ? ReactApplication )?.reactHost ? : return
67+ try {
68+ val delegate = ReflectionUtils .getField<Any >(reactHost, " mReactHostDelegate" )
69+ ReflectionUtils .setField(delegate, " jsBundleLoader" , latestJSBundleLoader)
70+ } catch (e: Exception ) {
71+ FLog .e(javaClass, " Failed to update JS bundle loader for OTA reload" , e)
72+ }
6973 }
7074
7175 private fun getAssetLoader (bundle : String ): JSBundleLoader ? {
0 commit comments