react-native-update 10.40.1 → 10.40.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -185,18 +185,26 @@ final class ReactReloadManager {
185
185
  }
186
186
 
187
187
  private static boolean isNewArchitectureEnabled(Context application) {
188
+ if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
189
+ return true;
190
+ }
191
+
188
192
  try {
189
193
  Class<?> buildConfigClass = Class.forName(application.getPackageName() + ".BuildConfig");
190
194
  Field newArchitectureField = buildConfigClass.getField("IS_NEW_ARCHITECTURE_ENABLED");
191
- return newArchitectureField.getBoolean(null);
195
+ if (newArchitectureField.getBoolean(null)) {
196
+ return true;
197
+ }
192
198
  } catch (Throwable ignored) {
193
199
  }
194
200
 
195
201
  if (application instanceof ReactApplication) {
196
202
  try {
197
203
  ReactNativeHost reactNativeHost = ((ReactApplication) application).getReactNativeHost();
198
- Method isNewArchEnabledMethod =
199
- reactNativeHost.getClass().getDeclaredMethod("isNewArchEnabled");
204
+ Method isNewArchEnabledMethod = getDeclaredMethodInHierarchy(
205
+ reactNativeHost.getClass(),
206
+ "isNewArchEnabled"
207
+ );
200
208
  isNewArchEnabledMethod.setAccessible(true);
201
209
  Object result = isNewArchEnabledMethod.invoke(reactNativeHost);
202
210
  return result instanceof Boolean && (Boolean) result;
@@ -207,6 +215,20 @@ final class ReactReloadManager {
207
215
  return false;
208
216
  }
209
217
 
218
+ private static Method getDeclaredMethodInHierarchy(Class<?> clazz, String methodName)
219
+ throws NoSuchMethodException {
220
+ Class<?> current = clazz;
221
+ while (current != null) {
222
+ try {
223
+ return current.getDeclaredMethod(methodName);
224
+ } catch (NoSuchMethodException ignored) {
225
+ current = current.getSuperclass();
226
+ }
227
+ }
228
+
229
+ throw new NoSuchMethodException(methodName);
230
+ }
231
+
210
232
  private static void reloadReactHost(Object reactHost, JSBundleLoader loader) throws Throwable {
211
233
  try {
212
234
  Field devSupportField = getCompatibleField(reactHost.getClass(), "useDevSupport");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update",
3
- "version": "10.40.1",
3
+ "version": "10.40.2",
4
4
  "description": "react-native hot update",
5
5
  "main": "src/index",
6
6
  "scripts": {
Binary file
Binary file