hrp-test-module
v0.0.10
Published
React Native Custom Module Boilerplate for IOS and Android
Downloads
5
Readme
react-native-custom-module
React Native Custom Module Boilerplate
Usage
getModuleList() fetches list of native modules. This is only boilerplate implementation to build native module in React Natve.
import CustomModule from 'react-native-custom-module';
CustomModule.getModuleList((error, list) => {
if (error) {
//error
} else {
console.log(list)
//array list returned [...]
}
});
Mostly Automatic Install
npm install react-native-custom-module@https://github.com/httpdeveloper/react-native-custom-module.git --save
react-native link react-native-custom-module
Manual Install
IOS
- npm install react-native-custom-module@https://github.com/httpdeveloper/react-native-custom-module.git --save
- In Xcode, in the project navigator, right click Libraries -> Add Files to [your project's name]
- add RCTCustomModule.xcodeproj from node_modules of your root project
- In Xcode, in the project navigator, Select your project. Add libRCTCustomModule.a to your project's -> Build Phases -> Link Binary With Libraries
Android
- npm install react-native-custom-module@https://github.com/httpdeveloper/react-native-custom-module.git --save
- Append the following lines in android/setting.gradle
include ':react-native-custom-module'
project(':react-native-custom-module').projectDir = new File(settingsDir, '../node_modules/react-native-custom-module/android')
...
...
- Add the following lines in android/app/build.gradle
dependencies {
...
compile project(':react-native-custom-module')
...
- Open android/app/src/main/java/['your-package-name']/MainApplication.java
.....
import com.dineshmaharjan.custommodule.CustomModulePackage;
public class MainApplication extends Application implements ReactApplication {
.....
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
...
new CustomModulePackage() // Add this package
...
);
}
...
}
Article
Article about custom module development in React Native on medium.com
License
MIT