Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NativeModules is {} #45391

Open
design-and-deliver opened this issue Jul 11, 2024 · 1 comment
Open

NativeModules is {} #45391

design-and-deliver opened this issue Jul 11, 2024 · 1 comment

Comments

@design-and-deliver
Copy link

design-and-deliver commented Jul 11, 2024

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:

  • 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:

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

  1. npm install
  2. npx react-native run-android
  3. app will load and Home component will render
  4. 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]

Reproducer

https://github.com/design-and-deliver/nativemodulesdebug

Screenshots and Videos

RUNTIME-SCREENSHOT

@netmaxt3r
Copy link
Contributor

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants