-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
How to make a React Native package? #3059
Comments
First of all you need to add a "main" field to your package.json. This basically tells the packager where the main entry point of the module is e.g.
Secondly, you need to export something from TestRating/node_modules/react-native-rating/index.ios.js so you can import it later. You can do this by setting module.exports
Then when you do Finally if you're having problems with NativeModules.RCTRatingManager being undefined make sure you have I wrote a device info module that is quite simple so if you're looking for a simple working example of a module then take a look: https://github.com/rebeccahughes/react-native-device-info |
Thank you so much for reply. |
Yes you create a Cocoa Touch Static Library in the module. I think there was some talk about automating the process in #235 and here: https://github.com/exponentjs/rem |
Thanks! It's helpful. |
@rebeccahughes I'm looking for some official documentation specifying correct way to create a native module library. I have come across this repo https://github.com/frostney/react-native-create-library but I'm not sure if that's the best way to go about creating a native react native library. Any help would be appreciated. Thanks |
I have written some codes that bridge native code to react native, and I want to make it to a package.
The project name is RCTRating.
RCTRating/package.json is like
And I create a new project "TestRating", and modify package.json to
And run npm install, the files is coped to node_modules/react-native-rating.
Then, I run the code.
In the TestRating/node_modules/react-native-rating/index.ios.js, I have
RCTRatingManager is
undefined
I have a file in
TestRating/node_modules/react-native-rating/ios/RCTRatingManager.h
, so it should not be undefined.Why? Please help me.
The text was updated successfully, but these errors were encountered: