What is React Native?
It is a JavaScript library which offers special React Components which we can use in the React App. These components are special because React Native will be able to compile and render them into Native Widgets for a platform like iOS and Android. It’s also giving access to Native APIs which will helps you to use the device camera or user location etc. Based on the App which we create in this, we will be writing the code fully in JavaScript and then React Native can connect to the Native Platform code with the help of pre-built functions available in it. Once we create the App, we can publish these apps to the AppStore (iOS) or Play Store (Android) like native apps.
In effect, React Native will give you full flexibility to write the code in JavaScript which will be converted into iOS and Android depends on our need. Also, we don’t need to learn Java, #C etc. Read more on https://reactnative.dev/
Now Let’s see what’s behind the React Native?
Like I said before, React Native offers special components which will be compiled to Native Widgets. <View>, <Text>, <Image> are a few core components which you will mostly work with. Read more about React Core Components here. https://reactnative.dev/docs/intro-react-native-components.
As you might have noticed that these components are like HTML tags except its start with a capital letter. If we take <View> as an example, the browser or native platform don’t know what components this is and how to compile its. Here is the magic of React Native which will compile it into <div> for browser, <ViewGroup> for Android and <UIView> for iOS. Now we know how this works behind the scenes.
Now one important point. We can split our code into two-part. One is Views (e.g <View>…</View>) which will be compiled to Native Views depends on the platform where they are running. The second part is the business logic in our code which we wrote using JavaScript will not get compiled to Native Platforms code. This will run in a special environment like a Virtual Machine hosted by React Native inside our App. And these modules know how to talk to Native Platform modules or APIs. We don’t need to worry about how these communications are working. All these things will be taken care of automatically. All we need to do is to write the code in JavaScript.
Conclusion
React Native will compile the Views to Native platforms code and Runs the business logic in a special environment created by the React Native inside our code. We just need to think about how to write the code in JavaScript.