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.

4
  • What's the issue? Commented Feb 1, 2019 at 9: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 Commented Feb 1, 2019 at 13:07
  • There is no module called react-native-module, so it doesn't work. Commented Feb 2, 2019 at 18:03
  • @10101010 so what would the module be called? Because I am importing a module called react-native-module github.com/814k31/TestReactNativeNativeModule/blob/master/RNApp/… Which is declared github.com/814k31/TestReactNativeNativeModule/blob/master/… Commented Feb 3, 2019 at 4:58

1 Answer 1

0

Metro bundler doesn't support symlinks...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.