diff --git a/packages/react-native/Libraries/ReactNative/AppRegistry.js b/packages/react-native/Libraries/ReactNative/AppRegistry.js index d073995be8c859..9448296efcdb56 100644 --- a/packages/react-native/Libraries/ReactNative/AppRegistry.js +++ b/packages/react-native/Libraries/ReactNative/AppRegistry.js @@ -13,7 +13,7 @@ import type {RootTag} from '../Types/RootTagTypes'; import type {IPerformanceLogger} from '../Utilities/createPerformanceLogger'; import type {DisplayModeType} from './DisplayMode'; -import BatchedBridge from '../BatchedBridge/BatchedBridge'; +import registerCallableModule from '../Core/registerCallableModule'; import BugReporting from '../BugReporting/BugReporting'; import createPerformanceLogger from '../Utilities/createPerformanceLogger'; import infoLog from '../Utilities/infoLog'; @@ -363,8 +363,8 @@ global.RN$SurfaceRegistry = { if (global.RN$Bridgeless === true) { console.log('Bridgeless mode is enabled'); -} else { - BatchedBridge.registerCallableModule('AppRegistry', AppRegistry); } +registerCallableModule('AppRegistry', AppRegistry); + module.exports = AppRegistry; diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/HeadlessJsTaskService.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/HeadlessJsTaskService.java index c5dfeb33de14f9..9fa6f58fe30775 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/HeadlessJsTaskService.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/HeadlessJsTaskService.java @@ -124,15 +124,11 @@ public void run() { @Override public void onDestroy() { super.onDestroy(); + ReactContext reactContext = getReactContext(); - if (getReactNativeHost().hasInstance()) { - ReactInstanceManager reactInstanceManager = getReactNativeHost().getReactInstanceManager(); - ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); - if (reactContext != null) { - HeadlessJsTaskContext headlessJsTaskContext = - HeadlessJsTaskContext.getInstance(reactContext); - headlessJsTaskContext.removeTaskEventListener(this); - } + if (reactContext != null) { + HeadlessJsTaskContext headlessJsTaskContext = HeadlessJsTaskContext.getInstance(reactContext); + headlessJsTaskContext.removeTaskEventListener(this); } if (sWakeLock != null) { sWakeLock.release();