- this is a scaffolding @ boilerplate @ codebase @ stereotype, whatever name you can come up with ...
- ... for a react native library development, which is by using this, there's no need to call
react-native-create-library
anymore - ... except if there are any later update released from new command package installation via npm, whether it is stable or not, by then you can call this repository "stable but outdated"
- react native version supported : 0.41.2
- android support
- gradle : 1.3.1
- build tools (default by gradle) : 27.0.3
- sdk version (compile and target) : 27
- be acknowledged that these are applied to library project only, not to application
- as for now this is for development on windows only
- as for now this is for android only
- for native react native 's installation only. expo based project not supported
- including a scaffolding to develop application project with support for the library development
- windows
- elevated privilege console (cmd)
- nodejs + npm
- yarn (
npm i -g yarn
) - react-native (
npm i -g react-native
)
- copy this repo to a local working directory. you may rename it as you want. from now it it your library project directory
- take out directory
app
. that is the directory for application development. put it somewhere else and rename it if you going to use it later. or get rid of it if you don't - edit
android/local.properties
. setsdk.dir
to point to your android sdk directory location - edit
package.json
. changename
to suit your preference and keep prefixreact-native-
. in case if you plan to publish it as online package later, make sure it is not yet registered here - open up console (command prompt)
- go to library project directory
yarn
yarn link
- go to application project directory
- if it is the one from repo,
yarn
- if it is an existing project, follow these
- open up
android/app/src/main/java/.../MainApplication.java
- insert
import com.reactlibrary.ReactLibraryPackage;
to the bottom of the import list- append
new ReactLibraryPackage()
as an argument ofArrays.<ReactPackage>asList()
insidegetPackages
functionprotected List<ReactPackage> getPackages() { return Arrays.<ReactPackage>asList(new MainReactPackage(), new ReactLibraryPackage()); }
- if your library name is changed or for existing project, follow these
- open up
android/settings.gradle
- append or edit below lines with your library name in the blank
include ':___' project(':___').projectDir = new File(rootProject.projectDir, '../node_modules/___/android')
- open up
android/app/build.gradle
- append or edit
compile project(':___')
to the bottom with your library name in the blank
yarn link ___
with name of your library frompackage.json
in the blankyarn publish
on library project directory to publish your library to npm.js
- connect device or run android simulator
- go to working directory from console
react-native run-android
- expected metro bundler console window is running and app is running showing a greeting message
- i wish i have time for this. maybe next time. for now, please refer here
- don't hesitate to submit your issue here