I understand that react-native link (see post)
is an automatic way to install native dependencies. The post above explain how to use the link
command but lacking the detail of when to use it. Should it be used after adding a component, every code change or after introducing new module to the app?

- 9,990
- 38
- 137
- 303
-
Possible duplicate of [The use of react-native-link command?](https://stackoverflow.com/questions/49874385/the-use-of-react-native-link-command) – Andrew Mar 19 '19 at 16:58
-
This article has already been linked in my post which explains how and without when. – user938363 Mar 19 '19 at 18:03
-
You only have to run `react-native link dependency-name` after you have installed a dependency that uses native code. You don't need to use it any other time than that. Once it has been linked you can forget about it, as you won't have to link that dependency again. – Andrew Mar 19 '19 at 19:22
2 Answers
Why we use react-native-link??
In this post, I will explain why we use react native link command and when we need to use this command or not?
First, we will understand what is native module??
Native Modules
Native modules are usually distributed as npm packages, apart from the typical javascript files and resources they will contain an Android and ios library project.
React Native provides an impressive amount of native modules that give you direct access to core platform APIs on both Android and IOS. For example react-native-maps, react-native-firebase, react-native-socketio etc.
These modules or packages contained both platform (Android and Ios) code.
Now coming on to the react native link
Those libraries which are use native code, in that case you'll have to add these files to your app. For linking those library with react native code need to run react-native-link
Here are the few steps to link your libraries that contain native code
Automatic linking
Step 1
Install a library with native dependencies:
$ npm install --save
Step 2
Link your native dependencies:
$ react-native link
Done! All libraries with native dependencies should be successfully linked to your iOS/Android project.
Where we don't use react-native-link??
Those components which are only written in javascript they are not using any native code (Android and Ios). There is no need to run react-native-link. For example rn-modal-picker, react-native-check-box etc.

- 2,512
- 1
- 13
- 32
You should check out this other answer: The use of react-native-link command?
You only need to run react-native link NAME_OF_PACKAGE
when you install a new package that has a native codebase, or without arguments if you want to do it for multiple of them.

- 351
- 2
- 5
-
This article has already been linked in my post which explains how and without when. Just click the `react-native link` in my post. – user938363 Mar 19 '19 at 18:04