0

When importing a react-native native module. There is an issue when importing the js from the project for example

import RNModule from 'react-native-module';

However importing RNModule using native modules works:

import { NativeModules } from 'react-native';
const { RNModule } = NativeModules;

Has anyone else experienced this?

I've already tried clearing all the recommended caches as well as rebuilding.

I've tried importing from both the project name react-native-module and the file name rn-module

Example project: https://github.com/814k31/TestReactNativeNativeModule

(Build and run instructions in README)

This is the import that doesn't work https://github.com/814k31/TestReactNativeNativeModule/blob/master/RNApp/App.js#L13

But this one does work.

When the button is clicked it will trigger a native Android function

https://github.com/814k31/TestReactNativeNativeModule/blob/master/rn-module/android/src/main/java/com/reactlibrary/RNModuleModule.java#L18

and should make Hello World From RNModule appear on the screen.

814k31
  • 55
  • 8
  • What's the issue? – Aditya Feb 01 '19 at 09:04
  • @HeisenBrg if I attempt to import the javascript file using this line `import RNModule from 'react-native-module';` I get `react-native-module` not found in haste module map However the package exists in NativeModules – 814k31 Feb 01 '19 at 13:07
  • There is no module called `react-native-module`, so it doesn't work. – 10101010 Feb 02 '19 at 18:03
  • @10101010 so what would the module be called? Because I am importing a module called `react-native-module` https://github.com/814k31/TestReactNativeNativeModule/blob/master/RNApp/package.json#L13 Which is declared https://github.com/814k31/TestReactNativeNativeModule/blob/master/rn-module/package.json#L3 – 814k31 Feb 03 '19 at 04:58

1 Answers1

0

Metro bundler doesn't support symlinks...

814k31
  • 55
  • 8