Skip to content

fix ReactActivity.getReactDelegate().reload() - #44223

Closed
Kudo wants to merge 1 commit into
react:mainfrom
Kudo:@kudo/reload-fix
Closed

fix ReactActivity.getReactDelegate().reload()#44223
Kudo wants to merge 1 commit into
react:mainfrom
Kudo:@kudo/reload-fix

Conversation

@Kudo

@KudoKudo commented Apr 23, 2024

Copy link
Copy Markdown
Contributor

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

  • bridge mode + debug build
  • bridgeless mode + debug build
  • bridge mode + release build
  • bridgeless mode + release build

@facebook-github-botfacebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Contributor A React Native contributor. p: Expo Partner: Expo Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Apr 23, 2024
@KudoKudo mentioned this pull request Apr 23, 2024
3 tasks
@analysis-bot

analysis-bot commented Apr 23, 2024

Copy link
Copy Markdown
PlatformEngineArchSize (bytes)Diff
androidhermesarm64-v8a19,411,011-11
androidhermesarmeabi-v7an/a--
androidhermesx86n/a--
androidhermesx86_64n/a--
androidjscarm64-v8a22,784,348+4
androidjscarmeabi-v7an/a--
androidjscx86n/a--
androidjscx86_64n/a--

Base commit: 849da21
Branch: main

arushikesarwani94 added a commit to arushikesarwani94/react-native that referenced this pull request Apr 23, 2024
…ct#44227)
Summary:
In react#44223 kudo identified the incorrect return type.
Differential Revision: D56497700
facebook-github-bot pushed a commit that referenced this pull request Apr 24, 2024
)
Summary:
Pull Request resolved: #44227
In #44223 kudo identified the incorrect return type.
Reviewed By: christophpurrer, philIip
Differential Revision: D56497700
fbshipit-source-id: 5d7fc7ef21c3d3033a2567eba51b613eb41f0a1a
@Kudo
Kudoforce-pushed the @kudo/reload-fix branch from 627b779 to 4f5dd70CompareApril 24, 2024 13:26
@Kudo

Kudo commented Apr 24, 2024

Copy link
Copy Markdown
ContributorAuthor

rebase main since #44227 was landed

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@arushikesarwani94 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

cipolleschi pushed a commit that referenced this pull request May 1, 2024
)
Summary:
Pull Request resolved: #44227
In #44223 kudo identified the incorrect return type.
Reviewed By: christophpurrer, philIip
Differential Revision: D56497700
fbshipit-source-id: 5d7fc7ef21c3d3033a2567eba51b613eb41f0a1a
@facebook-github-botfacebook-github-bot added the Merged This PR has been merged. label May 1, 2024
@github-actions

Copy link
Copy Markdown

This pull request was successfully merged by @Kudo in 5399223.

When will my fix make it into a release? | How to file a pick request?

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@arushikesarwani94 merged this pull request in 5399223.

cipolleschi pushed a commit that referenced this pull request May 2, 2024
Summary:
fixing some problem for `ReactActivity.getReactDelegate().reload()` from #43521:
- the `reload()` does not work for bridge mode on release build
[ANDROID] [FIXED] - Fixed app reloading for `ReactActivity.getReactDelegate().reload()`.
Pull Request resolved: #44223
Test Plan:
tried to temporary change toast.show as reload and test from rn-tester
```diff
--- 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
Reviewed By: fkgozali
Differential Revision: D56795975
Pulled By: arushikesarwani94
fbshipit-source-id: 895eab1927ba6db748ebb32c0fd5313f19cf9d1b
kosmydel pushed a commit to kosmydel/react-native that referenced this pull request May 6, 2024
…ct#44227)
Summary:
Pull Request resolved: react#44227
In react#44223 kudo identified the incorrect return type.
Reviewed By: christophpurrer, philIip
Differential Revision: D56497700
fbshipit-source-id: 5d7fc7ef21c3d3033a2567eba51b613eb41f0a1a
kosmydel pushed a commit to kosmydel/react-native that referenced this pull request May 6, 2024
Summary:
fixing some problem for `ReactActivity.getReactDelegate().reload()` from react#43521:
- the `reload()` does not work for bridge mode on release build
## Changelog:
[ANDROID] [FIXED] - Fixed app reloading for `ReactActivity.getReactDelegate().reload()`.
Pull Request resolved: react#44223
Test Plan:
tried to temporary change toast.show as reload and test from rn-tester
```diff
--- 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
Reviewed By: fkgozali
Differential Revision: D56795975
Pulled By: arushikesarwani94
fbshipit-source-id: 895eab1927ba6db748ebb32c0fd5313f19cf9d1b
kosmydel pushed a commit to kosmydel/react-native that referenced this pull request Jun 11, 2024
…ct#44227)
Summary:
Pull Request resolved: react#44227
In react#44223 kudo identified the incorrect return type.
Reviewed By: christophpurrer, philIip
Differential Revision: D56497700
fbshipit-source-id: 5d7fc7ef21c3d3033a2567eba51b613eb41f0a1a
kosmydel pushed a commit to kosmydel/react-native that referenced this pull request Jun 11, 2024
Summary:
fixing some problem for `ReactActivity.getReactDelegate().reload()` from react#43521:
- the `reload()` does not work for bridge mode on release build
## Changelog:
[ANDROID] [FIXED] - Fixed app reloading for `ReactActivity.getReactDelegate().reload()`.
Pull Request resolved: react#44223
Test Plan:
tried to temporary change toast.show as reload and test from rn-tester
```diff
--- 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
Reviewed By: fkgozali
Differential Revision: D56795975
Pulled By: arushikesarwani94
fbshipit-source-id: 895eab1927ba6db748ebb32c0fd5313f19cf9d1b
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA SignedThis label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.ContributorA React Native contributor.MergedThis PR has been merged.p: ExpoPartner: ExpoPartnerShared with MetaApplied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@Kudo@analysis-bot@facebook-github-bot@javache@arushikesarwani94