From 7577aea8fcf73518173c11c30a094ae87d5009f6 Mon Sep 17 00:00:00 2001 From: Arushi Kesarwani Date: Tue, 26 Mar 2024 14:39:34 -0700 Subject: [PATCH] React-Native-Restart in release (#43645) Summary: https://github.com/facebook/react-native/pull/43521 & https://github.com/facebook/react-native/pull/43588 aimed to fix `react-native-restart`, however in release `handleReloadJS()` is a no-op in [DisabledDevSupportManager](https://github.com/facebook/react-native/blob/ac714b1c3300d3a169bdcfec05d556e18a7b83ff/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DisabledDevSupportManager.java#L139) which is why this should not work. Fixing it by relying on `ReactHostImpl.reload()` instead for Bridgeless. Adding implementation of `DisabledDevSupportManager.handleReloadJS()` won't work as it would mean introducing circular dependency `devsupport` -> `runtime` Reviewed By: cortinico Differential Revision: D55342296 --- .../main/java/com/facebook/react/ReactDelegate.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java index 16fdf3efda5866..176fbf37b38e11 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java @@ -15,6 +15,7 @@ import androidx.annotation.Nullable; import com.facebook.infer.annotation.Assertions; import com.facebook.react.config.ReactFeatureFlags; +import com.facebook.react.devsupport.DisabledDevSupportManager; import com.facebook.react.devsupport.DoubleTapReloadRecognizer; import com.facebook.react.devsupport.interfaces.DevSupportManager; import com.facebook.react.interfaces.fabric.ReactSurface; @@ -228,7 +229,15 @@ public boolean onKeyLongPress(int keyCode) { public void reload() { DevSupportManager devSupportManager = getDevSupportManager(); if (devSupportManager != null) { - devSupportManager.handleReloadJS(); + // With Bridgeless enabled, reload in RELEASE mode + if (devSupportManager instanceof DisabledDevSupportManager + && ReactFeatureFlags.enableBridgelessArchitecture + && mReactHost != null) { + // Do not reload the bundle from JS as there is no bundler running in release mode. + mReactHost.reload("ReactDelegate.reload()"); + } else { + devSupportManager.handleReloadJS(); + } } }