What is it
React Native (RN) is a JavaScript open-source cross-platform mobile framework, designed for building truly native apps for mobile platforms (Android and iOS). It’s based on a JS library made by well-known Facebook site called React. Thus RN uses the same design as React, letting you compose a rich mobile UI from declarative components.
Main conception
React Native provides the benefits from both Native and Hybrid Mobile Apps.
RN lets you build apps using only JavaScript. However, unlike other hybrid mobile technologies you are not building Web App wrapped in a native container. JavaScript code-base is compiled to a mobile app identical to Android app using Java or iOS app using Obj-C.
Sounds a bit unreal. However, React Native allows to accelerate the building mobile applications across different platforms, thanks to the possibility of reusing most of the code between them.
In addition, at the back-end framework level, javascript (particularly Node.js) has begun to adopt event-driven architecture and models for application design. Because that kind of architecture is a programming approach rather than a language, event-driven apps can be written in any programming language. The architecture allows for minimal coupling, making it an excellent choice for modern, distributed application architectures. Aside from that, there are numerous other platforms in the market, such as vantiq, that might be able to provide visual editors, scripting editors, a rules system based on SQL and JavaScript, testing tools for debugging, tracing, and logging, and a visual tool for distributed deployment. These platforms are driven based on the events, making them effective in real-time data. If you’re wondering what is event driven architecture, you can read the blog posts that discuss about it to learn more.
History
There were many other attempts to do something similar before, for example:
PhoneGap – implementation of native components on web technologies launched in WebView
NativeScript – similar ideas as in React Native based on XML, JS, CSS
Xamarin – from Mono developers for Linux, applications are written in C #, this is Microsoft’s project.
Mark Zuckerberg mentioned about idea to bet more on native instead of HTML in 2012 He promised to deliver a better Facebook mobile experience. Jordan Walke found a way to generate UI elements for iOS from a background JS thread. Then they organised an Facebook team Hackathon to work at prototype and find the solution for the ability to build native mobile applications with this technology.
React Native was developed in 2015 by Facebook team and since that time the interest in this framework was rapidly growing. Now thousands of apps are using React Native. Among them: Facebook, Tesla, UberEats, Walmart, Bloomberg.
Let’s try to review strong and weak sides of React Native.
Pluses
Faster development process. Let’s bring your app from specification to release in a shorter time frame. React Native uses some tricks like Hot and Live Reloading feature enables developers to refresh your emulator instantly without recompilation. We can iterate quickly. That’s important.
Shared code-base between both iOS and Android. Major code-base can be shared across platforms. This reduces the complexity of developing two separate native apps and keeping them synced. Developer doesn’t need to switch between Xcode and Android Studio any more.
More than hybrid apps. Other hybrid frameworks like Cordova or Ionic limit you to the features developed by their technologies. Some even render your entire app in a WebView. This solution does not allow to use native user interface as well as some of a mobile device functionalities available via API. But RN provides the possibility to write native code at any point.
Modern development tools and JavaScript features. RN development uses JavaScript development environment with all new JavaScript features. Examples of dev tools: remote debugging plugin; Inspector like in web browsers which allows to inspect elements on simulators; performance panel to help you achieve 60 FPS animations.
Separately, I can highlight the Node Package Manager (NPM). RN developer can use this the best dependency management and ecosystem. Developer doesn’t need to download all resources on every single launch, reduces the painful workspace regeneration and sharing issues with Cocoa Pods, as well as manages dependencies with nested resolution to avoid incorrect versioning.Open Source, Facebook supported. RN is built by Facebook and it is open source software. This helps the developers to suggest changes to make the app more efficient. RN is free to use. Moreover, it allows developers (look here for an example of one) to fix bugs and even add their own features while they are designing the app.
Strong Community. React Native has one of the most active open source communities. Professional Android, iOS, Web developers bring new development concepts, suggest solutions of the most typical problems, reconsidered traditional architecture. Useful information, tricks and tips, issues solutions are available in a wide variety.
Minuses
Performance still have to be considered. Using the aforesaid third-party libraries and bridges reduces a mobile app performance. In addition, smartphone memory and processor use native components, which also affects performance.
Longer debugging. React Native increases speed of development, but as well increases the duration of the debugging process.
Not really open-sourced. Yes, React Native is open-source software, but it is owned by Facebook, controlled by them. It is possible to become risky in case of some factors. Facebook can easily stop the development of React Native, can stop the support, and problems will begin. What is more dangerous – Facebook can refuse developers using their framework on their projects for some reasons. Here I can recall how it was painful when Facebook bought Instagram and closed access to it’s API for newer developers.
Native code still required. To use some functions like accelerometer or camera you have to use native components, so there will be a separate code for Android and IOS. Developer can use third-party libraries, but they don’t cover every native function yet. Also, bridges have to be developed to link JavaScript and native components. This can increase development time, but only in case of platform depended specific functionality.
Concurrency. When we want to do some heavy computation like encryption or data transformation, all user interactions will be stuck because all JavaScript code is run under a single-threaded JavaScript engine. That is not good for an app concerned with user experience. Here the developer can do some tricks with the help of JavaScript message queue, the heavy computation still awaits there and gets ready for blocking the main thread. If you’d like to learn more about thread priority in java, you can head online and watch some related tutorials or read up on the topic.
On Cocoa, we have the wonderful Grand Central Dispatch, which abstracts thread management for us to do concurrent jobs. If we want to manage real threads on our own in RN, we can use leaking abstractions. We need to write a native module creating another JSVirtualMachine and exposes API to React Native. This can be the solution. But you should always consider performance issue in comparison between JavaScript and native solutions.
So, when it is worth
Consider these if you decide to develop in React Native
If you plan to build an app with RN and maintain it over a longer period of time, you need to prepare for more frequent updates than in native technologies (you need to update your app both when the platform has been updated and when new components have been added to React Native). This is not a disadvantage, as React Native is regularly updated and new useful components are created (monthly). But you have to remember about making more regular updates to your app. In the past developers struggled with the update process, but since version 0.59 you can make updates without any concern. Also share your plans with you mobile development partner to minimize potential risks – a mismatch between the technology and the development plans.
When is native mobile development better?
Note, that all of the recommendations below may become as less relevant as more new versions of RN are released…
Apps with complex user interfaces. JS allows to build fast and smooth apps. If your application’s user interface requires too much interactions, then React Native maybe not the best choice.
Apps that are designed for a single OS. The app will exclusively available on Android devices or exclusively available on iOS devices.
Media players, Utilities, complex features. Apps like antivirus software, battery monitors, media players almost always use native features and APIs provided by the underlying platform. So, such apps can be coded much more easily using native languages.
Complex features, for example:
• QR codes scanning
• OCR (Optical Character Recognition)
• AR (augmented reality) / VR (virtual reality)
• Voice assistants
When is React Native development better?
Short-term game. For example, for promotional campaigns. There is no complex features and the application will not live for long, so there is no need to worry about future scale and support.
Convert a website into an app. RN works on JS and websites use the same technology. That’s why, if you need to create a simple application that will show the data from your website, you can easily use React Native.
When planning simple standard features.
Conclusion
There are very clear advantages and disadvantages to going with React Native. Performance really does matter, as do developer costs and speed of development. The decision you make will depend on the exact details of your situation. The app your building, the amount of funding you have, and the skillset of your team and future team members.
A startup is often about iterating on ideas, and you don’t know what’s going to work and what isn’t. Developing mobile apps for startups for 3 platforms is important. But one should not later realize no one wants to use them which would be a real shame.
RN is a good choice not only for small companies, but also for large ones. Remember Tesla, Walmart, and Uber Eats?
Yes, they use RN only for part of their products, but this is maybe because they are almost sure that they will have huge revenue even if they spend much for separate teams of Android and iOS developers and so make their main products slightly better for millions of users.