To get set up with the basic project structure for a native module we will use a third party tool create-react-native-module. You can go ahead further and dive deep into how that library works, for our needs we will only need:
$ yarn global add create-react-native-module$ create-react-native-module MyLibrary
Where MyLibrary is the name you would like for the new module. After doing this you will navigate into
MyLibrary folder and install the npm package to be locally available for your computer by doing:
$ yarn install
After this is done you can go to your main react app folder (which you created by doing
react-native init MyApp)
- add your newly created module as a dependency in your package.json
yarn installto bring it along from your local npm repository.
After this, you will be able to continue to Native Modules (iOS) or Native Modules (Android) to add in some code. Make sure to read the README.md within your
MyLibrary Directory for platform-specific instructions on how to include the project.