fix ReactActivity.getReactDelegate().reload()
Summary:
fixing some problem for ReactActivity.getReactDelegate().reload() from #43521:
- the
reload()does not work for bridge mode on release build
Changelog:
[ANDROID] [FIXED] - Fixed app reloading for ReactActivity.getReactDelegate().reload().
Test Plan:
tried to temporary change toast.show as reload and test from rn-tester
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/toast/ToastModule.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/toast/ToastModule.kt
@@ -10,6 +10,7 @@ package com.facebook.react.modules.toast
import android.view.Gravity
import android.widget.Toast
import com.facebook.fbreact.specs.NativeToastAndroidSpec
+import com.facebook.react.ReactActivity
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.UiThreadUtil
@@ -30,9 +31,11 @@ public class ToastModule(reactContext: ReactApplicationContext) :
)
override public fun show(message: String?, durationDouble: Double) {
- val duration = durationDouble.toInt()
- UiThreadUtil.runOnUiThread(
- Runnable { Toast.makeText(getReactApplicationContext(), message, duration).show() })
+// val duration = durationDouble.toInt()
+// UiThreadUtil.runOnUiThread(
+// Runnable { Toast.makeText(getReactApplicationContext(), message, duration).show() })
+ val activity = reactApplicationContext.currentActivity as? ReactActivity
+ activity?.reactDelegate?.reload()
}
override public fun showWithGravity(
tried for different mode
- [x] bridge mode + debug build
- [x] bridgeless mode + debug build
- [x] bridge mode + release build
- [x] bridgeless mode + release build
| Platform | Engine | Arch | Size (bytes) | Diff |
|---|---|---|---|---|
| android | hermes | arm64-v8a | 19,411,011 | -11 |
| android | hermes | armeabi-v7a | n/a | -- |
| android | hermes | x86 | n/a | -- |
| android | hermes | x86_64 | n/a | -- |
| android | jsc | arm64-v8a | 22,784,348 | +4 |
| android | jsc | armeabi-v7a | n/a | -- |
| android | jsc | x86 | n/a | -- |
| android | jsc | x86_64 | n/a | -- |
Base commit: 849da2146ca27b7512f2f3ea0f8af8aa001e807a Branch: main
rebase main since #44227 was landed
@arushikesarwani94 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
This pull request was successfully merged by @Kudo in 539922339b5ca1937ce3207038199a27566914fe.
When will my fix make it into a release? | How to file a pick request?
@arushikesarwani94 merged this pull request in facebook/react-native@539922339b5ca1937ce3207038199a27566914fe.