Skip to content

Commit

Permalink
Fix Reload behavior being different on Bridgeless (#42917)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #42917

If the app is not connected to Metro, the behavior of the refresh is different between bridgeless and bridge. This is because the `handleReloadJS` is implemented differently between the two support managers. I'm fixing it.

Changelog:
[Android] [Fixed] - Fix Reload behavior being different on Bridgeless

Reviewed By: cipolleschi

Differential Revision: D53526369

fbshipit-source-id: 63509b5595c3738a1d6d9eb4352036c174643770
  • Loading branch information
cortinico authored and facebook-github-bot committed Feb 7, 2024
1 parent f0d1d92 commit 85257a9
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import com.facebook.debug.holder.PrinterHolder;
import com.facebook.debug.tags.ReactDebugOverlayTags;
import com.facebook.infer.annotation.Assertions;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.JSBundleLoader;
import com.facebook.react.bridge.JavaJSExecutor;
import com.facebook.react.bridge.JavaScriptExecutorFactory;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.devsupport.DevSupportManagerBase;
import com.facebook.react.devsupport.HMRClient;
import com.facebook.react.devsupport.ReactInstanceDevHelper;
Expand Down Expand Up @@ -93,8 +97,17 @@ public void onError(String url, Throwable cause) {

@Override
public void handleReloadJS() {
UiThreadUtil.assertOnUiThread();

// dismiss redbox if exists
hideRedboxDialog();
mReactHost.reload("BridgelessDevSupportManager.handleReloadJS()");

PrinterHolder.getPrinter()
.logMessage(ReactDebugOverlayTags.RN_CORE, "RNCore: load from Server");
String bundleURL =
getDevServerHelper().getDevServerBundleURL(Assertions.assertNotNull(getJSAppBundleName()));
reloadJSFromServer(bundleURL);
}

private static ReactInstanceDevHelper createInstanceDevHelper(final ReactHostImpl reactHost) {
Expand Down

0 comments on commit 85257a9

Please sign in to comment.