This project is converted bridge of bonjour RDNSS lib for React Native easy to import and use
There are many ways to do this, here's the way I do it:
-
Push it to GitHub.
-
Do
npm install --save git+https://github.com/HarshankArastu/react-native-android-library-boilerplate.git
in your main project. -
Link the library:
-
Add the following to
android/settings.gradle
:include ':react-native-android-library-boilerplate' project(':react-native-android-library-boilerplate').projectDir = new File(settingsDir, '../node_modules/react-native-android-library-boilerplate/android')
-
Add the following to
android/app/build.gradle
:... dependencies { ... compile project(':react-native-android-library-boilerplate') }
-
-
Simply
import/require
it by the name defined in your library'spackage.json
:import Boilerplate from 'react-native-android-library-boilerplate'
constructor(props){
super(props)
this.state = {
resultArray:[]
}
Boilerplate.getData();
}
async componentDidMount(){
this.setState({
resultArray : await Boilerplate.getBonjourDevicesList(),
})
}
```
- You can test and develop your library by importing the
node_modules
library into Android Studio if you don't want to install it from git all the time.# react-native-android-library-boilerplate