I've created a new React Native app with configuration for sharing Intents. My app icon shows up in the app share tray, and when the user taps the app icon in the app share tray - the emulator brings my app to the top as expected. Unfortunately, NativeModules is always an empty object ({}) in my RN component so I'm not able to access my custom module:
I've validated my current implementation with all of the AI chatbots
I've researched and posted to StackOverflow and Reddit
I've tried all of the different approaches that were mentioned in previous GitHub Issues threads
So I'm submitting this issue. Maybe I'm just missing something - which is quite possible since this is the first native module that I've implemented in RN. I've created the following repo as a very simple example to isolate the problem at hand:
It should be fully runnable with all of the required files and configurations. I'm really curious what the problem might be here.
Steps to reproduce
npm install
npx react-native run-android
app will load and Home component will render
check metro logs to see that NativeModules is {}
React Native Version
0.74.3
Affected Platforms
Runtime - Android
Output of npx react-native info
System:
OS: Windows 11 10.0.22621
CPU: (8) x64 Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
Memory: 2.50 GB / 15.80 GB
Binaries:
Node:
version: 18.18.0
path: C:\Program Files\nodejs\node.EXE
Yarn:
version: 3.6.4
path: ~\AppData\Roaming\npm\yarn.CMD
npm:
version: 9.8.1
path: C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK:
AllowAllTrustedApps: Disabled
Versions:
- 10.0.17763.0
IDEs:
Android Studio: AI-241.15989.150.2411.11948838
Visual Studio:
- 17.6.33723.286 (Visual Studio Community 2022)
- 16.11.33529.622 (Visual Studio Community 2019)
Languages:
Java: 17.0.11
Ruby: Not Found
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.74.3
wanted: 0.74.3
react-native-windows: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
Stacktrace or Logs
LOG [7/11/2024 12:13:36 PM] All Native Modules: {}
LOG [7/11/2024 12:13:36 PM] IntentModule - direct access: null
ERROR [TypeError: Cannot read property 'getSharedText' of null]
@design-and-deliver you will not be able to enumerate native modules by console.log
also You need to register your native module package to access from js side
Description
NativeModules is {}
I've created a new React Native app with configuration for sharing Intents. My app icon shows up in the app share tray, and when the user taps the app icon in the app share tray - the emulator brings my app to the top as expected. Unfortunately, NativeModules is always an empty object ({}) in my RN component so I'm not able to access my custom module:
So I'm submitting this issue. Maybe I'm just missing something - which is quite possible since this is the first native module that I've implemented in RN. I've created the following repo as a very simple example to isolate the problem at hand:
https://github.com/design-and-deliver/nativemodulesdebug
It should be fully runnable with all of the required files and configurations. I'm really curious what the problem might be here.
Steps to reproduce
React Native Version
0.74.3
Affected Platforms
Runtime - Android
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com/design-and-deliver/nativemodulesdebug
Screenshots and Videos