React Native serves to build mobile app with JavaScript, but its syntax doesn't look like a standard JS. Learn more about this technology and check if it's worth using.
A QUICK SUMMARY – FOR THE BUSY ONES
TABLE OF CONTENTS
React Native is a mobile app development framework that enables the development of multi-platform Android and iOS apps using native UI elements. It is based on the JavaScriptCore runtime and Babel transformers. With this setup RN supports new JavaScript (ES6+) features, e.g. arrow functions, async/await etc.
This famous framework for mobile app development started in the summer of 2013 as Facebook’s internal hackathon project. Its first public preview was released in January of 2015 at Reactjs Conference and in March of 2015, Facebook made React Native open and available on GitHub.
Since then, it has been widely adopted by developers and organizations because of its ability to produce native apps and great User Interfaces. In the graph below, you can visualize the increasing trend for React Native. In just 1.5 years after its release, it overtook Android and iOS development.
So now, you should not be surprised by the fact that many of the apps we use today have business logic built using mostly JavaScript rather than Java/Kotlin or Objective-C/Swift. Some of them are Myntra, UberEats, Facebook, and Instagram.
Since we talked about what is React Native, you might be confused about what ‘native app’ means.
Native mobile apps are apps which are specifically created for an operating system, either Android or iOS in this case. For building a native app on iOS, we use Objective-C/Swift development language and for Android we use Java/Kotlin.
Coming to React Native, the final User Interface does not simply render a web component inside a WebView. The User Interface is rendered using actual native views and fundamental building blocks that are indistinguishable from the apps built using Swift or Java.
Before we go into the details of what is React Native, let’s first find out what is React JS:
React Native resembles React JS, however, it utilizes native components rather than web component as crucial building blocks. You have to see a portion of the fundamental React ideas, as JSX(JavaScript XML), components, state, and props to grasp the essential structure of a React Native application.
However, if you are interested in building apps in React Native, learning React JS is not strictly mandatory, you can simply start with React Native.
We have partially answered this question at the beginning of the article. We didn’t, however, address any technical aspects of its architecture. In this section, we will focus on how React Native works.
Let’s start by looking at the default React Native application, like the one below.
import React from 'react';
import { Text, View } from 'react-native';
export default class Brainhub extends React.Component {
render() {
return (
What is React Native
);
}
}
If you are a web developer familiar with older standards of JS only, a portion of the above snippet probably won’t look like JavaScript to you. ES2015 (otherwise called ES6) is a lot of enhancement to JavaScript that is presently a part of the official standard. ES6 isn’t upheld by older browsers, that’s why there is a need of using transpilers like Babel.
Thanks to Babel transpiler React Native supports many features of JavaScript ES2015, so you can utilize this technology without stressing over its compatibility with different devices. Some of the features of ES2015 in the given snippet are import, from, and class. If you aren’t comfortable with ES2015, you can pick it up just by going through sample codes from the resources listed under the resource section.
This is JSX, a grammar for encapsulating XML inside JavaScript. It allows you to write your code inside markup language. It appears like HTML that we use in web development, but instead of using <div> or <span>, you will utilize React Native components. Here, <Text> is a built-in component that just shows some content and View resembles <div> or <span>.
This was an example of displaying “What is React Native”. This line of text acts as a component. Anything you see on the screen is a type of component. It can be really straightforward. The main thing required is a render function, which returns some JSX to render.
Each such component maps to native building blocks when we synthesize our React Native App to Android or iOS Apps. Like in this case <Text> is mapped to <TextView/> in Android and UILabel in iOS.
React Native, as any other technology has its advantages and disadvantages. Before you decide whether React Native is a good fit for your particular project, have a look at the cheat sheet below.
The primary advantage of this system is that it is timesaving. Initially, it spares the developers from recompiling with each change, since the application reloads right away amid the improvement stage. An Android designer can comprehend the torment.
The framework empowers the making of a solitary code base that can be blended for iOS and Android. It enables the engineer to invest less energy in coding.
A mobile application, imagined with this framework guarantees high caliber, phenomenal execution, and streamlined user experience.
Besides that, an all-around prepared JavaScript engineer can develop a versatile application utilizing this framework without diving into the ecosystem and language specifics of each OS.
The subsequent User Interface is exceedingly responsive and feels liquid on account of asynchronous JavaScript connections with the local condition.
This implies that the application will have faster loading times and smoother feel than the one built using a hybrid model.
It is a complex procedure to debug an app built from React Native. You will have to look into the manner in which React Native produces the code and decide how to act on it.
Sometimes, local library coordination inside a React Native application requires plenty of configurations. For instance, a Google Maps outline turns into a long haul work while it takes one moment on an Android Native application.
Ionic and Cordova are some of the other frameworks which are used for similar purposes. They make the so-called hybrid applications. These are created with standard Web innovations and are encapsulated in native fundamental components like WebView. Not at all like React Native, hence it is a genuine overlay to native development.
As we already mentioned, React Native uses native building blocks and is not an overlay to the Operating System. In fact, the JavaScript composed code is synthesized into native codes (fundamental building blocks). So we end up with an application that uses fully native components that are controlled by JavaScript thread instead of web application placed inside WebView component.
The Cordova or Ionic produced graphical interface is shown through a Web View, which expels its productivity and quality and also the client experience. Apps with built with this technology lack in native UX fee.
In this article, we saw that React Native is similar to React, which itself is a JavaScript library to make interfaces. Consequently, you need to ace web technologies like JavaScript, JSX and even CSS-like stylesheet syntax for component customization. Despite having a few complexities, the React Native Framework has breezed through every one of the tests and obstacles to end up as the first choice for many developers.
Our promise
Every year, Brainhub helps 750,000+ founders, leaders and software engineers make smart tech decisions. We earn that trust by openly sharing our insights based on practical software engineering experience.
Authors
Read next
Popular this month