Export NativeModules for NPM in React-Native

873 views Asked by At

I'm trying to create a node module from my React Native App. The problem is, that the module is mostly a NativeModule. So my index.js looks like this:

import { NativeModules } from 'react-native';
export default NativeModules.MyNativeClass;

When i install my package to my node_modules (inserted local relative path to package.json) and import it to my JS file, it's always undefined. I tried to export a test object, like export default {test:'test'}; and it works. So, is it possible to export the Native Module through node_modules?

1

There are 1 answers

0
Jonas Laux On

If anyone is stuck to the same issue. Just link it with

react-native link

and your native modules from your node_modules get visible.