I want to link only one of my project (Android or iOS) with the npm package. Is there any way to do it?
Yes, we can. React Native smoothly combines the components written in Objective-C, Java, or Swift.
Deep Linking is a technique in which a given URL or resource is used to open a specific page or screen on mobile. So, instead of just launching the app on mobile, a deep link can lead a user to a specific screen within the app, providing a better user experience.
You can choose to link libraries for only a certain platform by doing:
For Android: react-native link (your_library_name_here) --platforms android
For iOS: react-native link (your_library_name_here) --platforms ios
if react-native < 60
react-native link your-library-js-package-name
..
react-native >= 60
because the new react-native versions have some auto-linking feature you should tell the react-native CLI to do not link your library:
react-native.config.js
file in the root of your project.add some config like this
module.exports = {
dependencies: {
'your-library-js-package-name': {
platforms: {
android: null, // assign null to disable autolinking
ios: // assign null to disable autolinking or remove the
ios key to let do the default linking
},
},
},
};
check this for more info docs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With