diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/BridgelessCatalystInstance.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/BridgelessCatalystInstance.kt index 434c8ead80c3fe..03a18c6c8dae01 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/BridgelessCatalystInstance.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/BridgelessCatalystInstance.kt @@ -92,25 +92,20 @@ public class BridgelessCatalystInstance(private val reactHost: ReactHostImpl) : throw UnsupportedOperationException("Unimplemented method 'initialize'") } - override fun getReactQueueConfiguration(): ReactQueueConfiguration { - throw UnsupportedOperationException("Unimplemented method 'getReactQueueConfiguration'") - } + override fun getReactQueueConfiguration(): ReactQueueConfiguration = + reactHost.reactQueueConfiguration!! - override fun getJSModule(jsInterface: Class): T { - throw UnsupportedOperationException("Unimplemented method 'getJSModule'") - } + override fun getJSModule(jsInterface: Class): T = + reactHost.currentReactContext?.getJSModule(jsInterface)!! - override fun hasNativeModule(nativeModuleInterface: Class): Boolean { - throw UnsupportedOperationException("Unimplemented method 'hasNativeModule'") - } + override fun hasNativeModule(nativeModuleInterface: Class): Boolean = + reactHost.hasNativeModule(nativeModuleInterface) - override fun getNativeModule(nativeModuleInterface: Class): T? { - throw UnsupportedOperationException("Unimplemented method 'getNativeModule'") - } + override fun getNativeModule(nativeModuleInterface: Class): T? = + reactHost.getNativeModule(nativeModuleInterface) - override fun getNativeModule(moduleName: String): NativeModule? { - throw UnsupportedOperationException("Unimplemented method 'getNativeModule'") - } + override fun getNativeModule(moduleName: String): NativeModule? = + reactHost.getNativeModule(moduleName) @Deprecated( message = @@ -119,9 +114,7 @@ public class BridgelessCatalystInstance(private val reactHost: ReactHostImpl) : throw UnsupportedOperationException("Unimplemented method 'getJSIModule'") } - override fun getNativeModules(): Collection { - throw UnsupportedOperationException("Unimplemented method 'getNativeModules'") - } + override fun getNativeModules(): Collection = reactHost.getNativeModules() override fun extendNativeModules(modules: NativeModuleRegistry) { throw UnsupportedOperationException("Unimplemented method 'extendNativeModules'") diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java index 9c489a85b3c990..8c3a378dc6f7e1 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java @@ -590,6 +590,16 @@ T getNativeModule(Class nativeModuleInterface) { return null; } + /* package */ + @Nullable + NativeModule getNativeModule(String nativeModuleName) { + final ReactInstance reactInstance = mReactInstanceTaskRef.get().getResult(); + if (reactInstance != null) { + return reactInstance.getNativeModule(nativeModuleName); + } + return null; + } + /* package */ @Nullable RuntimeExecutor getRuntimeExecutor() {