Skip to content

Commit ee4cbb3

Browse files
authored
Merge pull request #77 from Soomgo-Mobile/v11-drop-73
mod!: simplify and remove legacy code for RN 0.73
2 parents 1bed4a6 + c7e5646 commit ee4cbb3

File tree

3 files changed

+10
-43
lines changed

3 files changed

+10
-43
lines changed

README.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,9 @@
88

99
### 🚀 New Architecture support
1010

11-
Tested on the React Native template apps
12-
13-
| RN Version | Old Architecture | New Architecture | New Architecture Bridgeless |
14-
|--------|--------|--------|--------|
15-
| 0.73.11 ||| Unsupported |
16-
| 0.74.7 ||||
17-
| 0.75.5 ||||
18-
| 0.76.7 ||||
19-
| 0.77.1 ||||
20-
| 0.78.0 ||||
11+
Supports React Native 0.74 ~ 0.80.
2112

13+
(Tested on the React Native CLI template apps)
2214

2315
## 🚗 Migration Guide
2416

android/app/proguard-rules.pro

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
private ** mReactHost; # bridgeless
2525
public void reload(...); # RN 0.74 and above
2626
}
27-
# RN 0.74 and above
28-
-keepclassmembers class com.facebook.react.ReactActivity {
29-
public ** getReactDelegate(...);
30-
}
3127
# bridgeless
3228
-keepclassmembers class com.facebook.react.defaults.DefaultReactHostDelegate {
3329
private ** jsBundleLoader;

android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ private void setJSBundle(ReactInstanceManager instanceManager, String latestJSBu
128128

129129
ReactHost reactHost = resolveReactHost();
130130
if (reactHost == null) {
131-
// Bridge, Old Architecture and RN < 0.74 (we support Bridgeless >= 0.74)
131+
// Bridge, Old Architecture
132132
setJSBundleLoaderBridge(instanceManager, latestJSBundleLoader);
133133
return;
134134
}
@@ -184,29 +184,14 @@ private void loadBundle() {
184184
new Handler(Looper.getMainLooper()).post(new Runnable() {
185185
@Override
186186
public void run() {
187-
try {
188-
// reload method introduced in RN 0.74 (https://github.com/reactwg/react-native-new-architecture/discussions/174)
189-
// so, we need to check if reload method exists and call it
190-
try {
191-
ReactDelegate reactDelegate = resolveReactDelegate();
192-
if (reactDelegate == null) {
193-
throw new NoSuchMethodException("ReactDelegate doesn't have reload method in RN < 0.74");
194-
}
187+
ReactDelegate reactDelegate = resolveReactDelegate();
188+
assert reactDelegate != null;
195189

196-
resetReactRootViews(reactDelegate);
190+
resetReactRootViews(reactDelegate);
197191

198-
Method reloadMethod = reactDelegate.getClass().getMethod("reload");
199-
reloadMethod.invoke(reactDelegate);
200-
} catch (NoSuchMethodException e) {
201-
// RN < 0.74 calls ReactInstanceManager.recreateReactContextInBackground() directly
202-
instanceManager.recreateReactContextInBackground();
203-
}
204-
mCodePush.initializeUpdateAfterRestart();
205-
} catch (Exception e) {
206-
// The recreation method threw an unknown exception
207-
// so just simply fallback to restarting the Activity (if it exists)
208-
loadBundleLegacy();
209-
}
192+
reactDelegate.reload();
193+
194+
mCodePush.initializeUpdateAfterRestart();
210195
}
211196
});
212197

@@ -247,13 +232,7 @@ private ReactDelegate resolveReactDelegate() {
247232
return null;
248233
}
249234

250-
try {
251-
Method getReactDelegateMethod = currentActivity.getClass().getMethod("getReactDelegate");
252-
return (ReactDelegate) getReactDelegateMethod.invoke(currentActivity);
253-
} catch (Exception e) {
254-
// RN < 0.74 doesn't have getReactDelegate method
255-
return null;
256-
}
235+
return currentActivity.getReactDelegate();
257236
}
258237

259238
private ReactHost resolveReactHost() {

0 commit comments

Comments
 (0)