Connecting different platforms to JavaScript
In the first subsection of this section, we’ll focus on Android and iOS because these are the most common platforms. At the end of this section, we’ll also have a look at how to deploy to the web, Mac, Windows, and even other platforms.
First, it is important to understand that React Native provides a way of communication between JavaScript and Native. Most of the time, you don’t need to change anything on the native side because the framework itself or some community libraries cover most of the native functionalities, but nevertheless, it is important to understand how it works.
Let’s start with the UI. When you write your UI in JavaScript, React Native maps your JSX components such as View
and Text
to native components such as UIView
and NSAttributedString
on iOS or android.view
and SpannableString
on Android. The styling of these native components is done using a layout engine called Yoga.
While...