Can React Native be a replacement for native apps?
On many occasions, we had to deal with customers interested in creating mobile applications for Android and iOS. Unfortunately, when they receive a quote, they are disappointed, because it significantly exceeds the budget they have. In such cases, we offer them to develop React Native apps. However, this raises suspicions – how is it that the initial valuation was so high and now suddenly we can offer something much cheaper? Where do we save money? And why did we not immediately recommend this technology? There is no general answer to these questions. We can only explain what React Native is and what it is not, what are the pros and cons of this technology.
To have a cake and eat a cake
It all started with Facebook. In 2012, Mark Zuckerberg admitted that the reliance on HTML5 as a universal app platform for mobile devices failed. Despite the claims of browser manufacturers and niche systems such as BlackBerry OS and Firefox OS, HTML5 apps have never even come close to native Android and iOS apps in terms of capabilities and convenience. So Zuckerberg has promised that in the future Facebook will find a way to work better on mobile devices.
The first version of React Native was presented in 2015 and quickly became one of the hottest topics in the software industry. It combines the advantages of web applications (fast development, easy programming) with the advantages of native applications (quick access to the components and animations of the user interface).
How does React Native draw user interfaces?
To understand how React Native technology works on a mobile system, you should first consider the Virtual DOM mechanism from the React.js library. It works as a layer between the description of how the interface should look like and the work done in order to actually render the interface on the website. The interactive user interface on the website is possible only by continuously modifying the so-called object-oriented document model (DOM) of the browser.
In the case of React Native on a mobile device, obviously, you do not modify your browser’s DOM. React Native calls Objective-C interfaces to draw components on iOS or Java interfaces to draw components on Android. This call is possible thanks to a special bridge that provides an interface to native elements of the platform. Components from React return a description of how the interface should look like, and React Native translates this description into compatible ones with iOS or Android.
Thanks to this simple <View> (equivalent to <div> from HTML) turns on iOS into a native UILabel or UITextView controls, and on Androids into a native TextView control.
From web technologies to native technologies
In fact, you may notice that this approach of combining web technologies with mobile devices has already existed. This is obviously a technology called Apache Cordova, formerly known as PhoneGap. Cordova is a kind of native container around a web application that provides interfaces normally unavailable through a web browser. However, if we take a closer look, we will notice that React Native has nothing to do with Cordova. The application written in React Native is not a website, while the application in Cordova container does not have any access to native iOS or Android interface elements. Even a layman will see the difference in performance and fluidity.
If React Native apps are so efficient and fast, why not save money and not just stop writing native software for mobile systems? The answer is simple – because they are only efficient and fast in terms of the user interface.
So if an application needs efficient, multi-threaded business logic, React Native will work much more slowly. Likewise, the more of these application logic interactions with the user interface, the more it will reduce performance. There are some methods of increasing performance – e.g. writing demanding application elements in C/C+++ language, but this will require building special bridges for them, which is associated with additional costs.
Another limitation is that not all views available in React Native are actually native views that are available from the platform. It is said that React Native will achieve full consistency with the release of version 1.0 (version 0.56 is available in August 2018), but nobody knows when it will happen. You should remember that this is a Facebook platform, developed primarily for Facebook mobile applications.
When is it worth to choose React Native?
On the other hand, if the application is complex and demanding, where little code can be shared and a lot of work will be done on building bridge modules, it is better to program natively for Android and iOS from the very beginning. It should also be remembered that React Native is quickly evolving and changing, and this means that maintaining applications written in it may be more expensive than applications written in Objective-C or Java. In newer versions of React Native, many things can work completely different than before – and all this you will need to cover.
Advantages of React Native apps
- one code for many platforms (in theory you can go beyond iOS and Android, creating a new bridge for the next platform),
- one team of programmers,
- a rapid development of applications in web technologies,
- simple synchronization of application development and updates between mobile platforms,
- based on React.js, which is a really good programming framework,
- a lower price of creating a mobile application,
Restrictions of React Native apps
- the high cost of maintenance and application development due to the rapid development of the framework,
- limited compliance with Apple and Google interface design guidelines.
Also published on Medium.