Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly does "react-native link" do?

My understanding is that if you have a native module, 'react-native link' allows you to use that module in your project. If you have some insight on any of the following questions, please do share:

1) I've seen that running 'react-native link' adds the corresponding .xcodeproj file to the Libraries folder in xcode, but how does this allow you to use the module in your project? And what does running 'react-native link' do besides add this file to this folder?

2) The components that React Native comes with out-of-the-box like , those access native functionality too, right? But we don't have to link them. Does this mean they're linked by default?

3) If those components ^^ like do come pre-linked, why can't we do this with new native modules that we install? I assume that running 'react-native link' adds something to the project that is machine-specific, but which machine would that be? The one I'm developing on?

Thanks :)

like image 392
gkeenley Avatar asked Jan 10 '19 23:01

gkeenley


People also ask

Is react-native link deprecated?

The post `react-native link` without package name is Deprecated is regarding the deprecation of react-native link without the package name. If you are using a library with some native functionality then you need to make some changes in the Android and IOS files and that is called linking.

How do you open a link in react-native?

The example React Native Clicking on a Text Hyperlink to open it in the Browser will show you how to click on a link / URL to open it in the default browser. Clicking on a link and open it in the browser can be done using a React Native component called Linking .


1 Answers

1) By Linking, i do believe it kind of copy/install/put together the necessary files for the module(s) and import/add those dependencies into the relevant Android and iOS specific folders/files which's what make them work and be available to the RN project.

2) Not sure but those Components act like a set of defaults which comes built-in in the RN package. It may also be seen as a set of Blocks that the RN team decided to ship together. I think there's no problem in seeing/threating them as default linked modules.

3) Newly added native modules must be linked because they are out of the "default scope" of the project and in order to be available to the RN platform, they must follow the linking process. Although it's not fun to link every single module, sometimes it's necessary, especially if you modify the default boot routine/sequence

Hope it helps ^.^

like image 92
Andrei Vedovato Avatar answered Oct 07 '22 18:10

Andrei Vedovato