6 reasons to learn React Native

React Native was created in 2015 by Facebook developers as a framework to build sophisticated mobile apps using JavaScript and React (a web framework). When it was released, it was seen as either revolutionary or naive, because so far JavaScript had been a poor choice for developing mobile apps. Today, some 3 years later, the framework and the community around have grown mature enough that it's easily a good choice for professional development of apps for Android and iOS. Let's see a couple of reasons why.

Modern way to build a mobile app

Typically, to create a mobile app, first you must make a decision between the two dominating platforms: Android or iOS. That choice will affect the tools to use, since these two platforms have entirely different software development kits (SDKs). The tooling sometimes takes minutes or hours to download and setup. After that, the first app template takes a minute to compile. Only then, will you see an app on the device and can start programming, that is, if you have learned the languages (Java for Android, ObjectiveC or Swift for iOS) and their development kits. Once you make a code change, the app needs to be recompiled. These SDKs follow an old style of application development.

With React Native, the development workflow is closer to web development. First of all, you don't need to make a choice between one platform or another. Whichever you choose, you'll download the same tools to begin with.

Then, when running one command in the terminal,create-react-native-app you will have an initial project to work on. Install it on the device, and after that you can reload the app in the same way you can reload a website, leading to shorter development cycles. This way, React Native has reinvented mobile development to be modern like web development.

JavaScript is the world's most commonly known programming language among developers, and it's the language used to develop apps in React Native. While ObjectiveC and Swift can be nice languages with interesting properties, they are outside of the comfort zone of many programmers.

Other frameworks on the same level as React Native, such as Xamarin and Flutter, utilize different and less popular languages, respectively: C# and Dart. Hence React Native is has unique qualities when it comes to popularity.

Not only is the language popular, but also the library for UI components, React, has been growing to become the most commonly known web framework. Both JavaScript and React are comfort zone technologies for a majority of programmers today.

Real native user interfaces

There are other JavaScript frameworks to build mobile apps, such as Apache Cordova and tools built on top of Cordova. These are also known as "hybrid mobile apps" frameworks, because they produce apps that are basically small websites ("WebViews") packaged as if they were actual apps. The result is not always a great user experience, even though the apps are convincing and can be used in practice.

React Native takes a different approach. The resulting apps have UI components built with the platform's official SDK, but orchestrated behind the scenes with JavaScript. This means there are no WebViews involved, and the user often cannot recognize the difference between a React Native app and one built with the platform's SDK, leading to better user experience.

Cross platform

Since JavaScript controls native Android and iOS UI components behind the scenes, it's possible for a JavaScript React component to be supported by both platforms. This gives developers some possibility to reuse code.

The framework focuses on "learn once, write everywhere", though, because not all UI components should be exactly the same for both platforms. For instance, Android and iOS have different design guidelines, which means often one Android UI component should not exist in iOS.

That said, many components can have the same look and feel on both platforms, and that's how React Native allows those to be coded just once. The convenience of using one codebase and one framework for building apps for two platforms saves development time.

Share code from browser or server

There are many frameworks that allow cross platform app development, but few that allow you to take snippets of browser code or server code and include that in the mobile app.

Since JavaScript runs in the browser and on servers (Node.js), there are thousands of libraries from npm that could be reused from one context to another. Some libraries don't make any assumption about the context they are running in, for instance, Date libraries such as Moment.js. Those could be easily utilized in the browser, in the server, and in React Native apps. This kind of universal usage of libraries is an exciting benefit of React Native.

Not a lock-in

React Native is open source (MIT license), but it's also important that it doesn't lock you into this choice in the long run. You can choose to develop only one screen of your app using React Native, while the other screens are built with the official SDKs. Or, you can develop all screens in React Native, or anything in between. It allows itself to be partially used in the project.

This creates a path for migrating away from React Native if you so wish in the future, or creates a path for you to migrate an existing app to React Native. That kind of flexibility is important for business and managers to allow developers to evolve the codebase while minimizing risk.

If you want to learn more about React Native, and how to actually start coding with it, be sure to participate in our Code in the Woods training to be held on 21st and 22nd of April. Welcome!