Skip to content

Commit

Permalink
Expose ReactDelegate for react-native-restart (#43588)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #43588

Supported `reload()` in Bridgeless through ReactDelegate in #43521 in order to unblock react-native-restart

https://github.com/avishayil/react-native-restart/blob/134cabd5b3f355ffe551e5dd1be1dd46d870fe13/android/src/main/java/com/reactnativerestart/RestartModule.java#L54

which can access React Delegate through :
```
if(currentActivity instanceof ReactActivity) {
    ReactActivity reactActivity = (ReactActivity) currentActivity;
    ReactDelegate reactDelegate = reactActivity.getReactDelegate();
    reactDelegate.reload()
}
```

Changelog:
[Android][Added] Expose ReactDelegate in ReactActivity

Reviewed By: cortinico

Differential Revision: D55166962

fbshipit-source-id: 5d8dfd7ad61edbcb5233014800eb66a538842ca5
  • Loading branch information
arushikesarwani94 authored and facebook-github-bot committed Mar 21, 2024
1 parent c574ca5 commit 62ebe55
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public abstract class com/facebook/react/ReactActivity : androidx/appcompat/app/
protected fun <init> ()V
protected fun createReactActivityDelegate ()Lcom/facebook/react/ReactActivityDelegate;
protected fun getMainComponentName ()Ljava/lang/String;
public fun getReactDelegate ()V
protected final fun getReactInstanceManager ()Lcom/facebook/react/ReactInstanceManager;
protected final fun getReactNativeHost ()Lcom/facebook/react/ReactNativeHost;
public fun invokeDefaultOnBackPressed ()V
Expand Down Expand Up @@ -113,6 +114,7 @@ public class com/facebook/react/ReactActivityDelegate {
protected fun getLaunchOptions ()Landroid/os/Bundle;
public fun getMainComponentName ()Ljava/lang/String;
protected fun getPlainActivity ()Landroid/app/Activity;
protected fun getReactDelegate ()Lcom/facebook/react/ReactDelegate;
public fun getReactHost ()Lcom/facebook/react/ReactHost;
public fun getReactInstanceManager ()Lcom/facebook/react/ReactInstanceManager;
protected fun getReactNativeHost ()Lcom/facebook/react/ReactNativeHost;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ protected void onDestroy() {
mDelegate.onDestroy();
}

public void getReactDelegate() {
mDelegate.getReactDelegate();
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ public ReactHost getReactHost() {
return ((ReactApplication) getPlainActivity().getApplication()).getReactHost();
}

protected @Nullable ReactDelegate getReactDelegate() {
return mReactDelegate;
}

public ReactInstanceManager getReactInstanceManager() {
return mReactDelegate.getReactInstanceManager();
}
Expand Down

0 comments on commit 62ebe55

Please sign in to comment.