Skip to content

Commit 2f46a49

Browse files
lukmccallfacebook-github-bot
authored andcommitted
Fix ReactHostImpl.nativeModules always returning an empty list (#52986)
Summary: During the Expo QA process, we discovered that `ReactContext.reactApplicationContext.nativeModules` always returns an empty list (https://github.com/expo/expo/blob/4e2bbb23edda74d0e24756fd1735b8763e38f7a7/packages/expo-modules-core/android/src/main/java/expo/modules/kotlin/ReactExtensions.kt#L12). This happens because, during object creation, the `reactInstance` is always null. ## Changelog: [ANDROID] [FIXED] - Fix `ReactHostImpl.nativeModules` always returning an empty list Pull Request resolved: #52986 Test Plan: - RN tester compiles ✅ Reviewed By: mdvacca Differential Revision: D79451613 Pulled By: cortinico fbshipit-source-id: d5341bcc1193eb948db4e99f16ba32a63073a6db
1 parent f273c63 commit 2f46a49

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,8 @@ public class ReactHostImpl(
521521
internal fun <T : NativeModule> hasNativeModule(nativeModuleInterface: Class<T>): Boolean =
522522
reactInstance?.hasNativeModule<T>(nativeModuleInterface) ?: false
523523

524-
internal val nativeModules: Collection<NativeModule> = reactInstance?.nativeModules ?: listOf()
524+
internal val nativeModules: Collection<NativeModule>
525+
get() = reactInstance?.nativeModules ?: listOf()
525526

526527
internal fun <T : NativeModule> getNativeModule(nativeModuleInterface: Class<T>): T? {
527528
if (!ReactBuildConfig.UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE &&

0 commit comments

Comments
 (0)