How was ReactJS developed

oreillyblog

A guest article by Erik Behrends, author of the book "React Native".

Anyone who wants to develop an app for smartphones is faced with many questions. And this is very central: should the app be developed for Android devices first or for iPhones first? Although the market share of Android is higher than that of iOS, all users can only potentially be reached if the app runs on both platforms.

If now for Android and iOS is to be developed, the traditional approaches of Google and Apple require two development teams and separate code. Both teams specialize in the different aspects, because with Java (or Kotlin) for Android and Swift for iOS not only different programming languages, but also their own APIs and tools are used. So it makes sense to develop the app across platforms in order to minimize the effort.

But which framework should be chosen for this?

Freshly published in January: 260 pages of React Native know-how from Erik Behrends. The book is now available in online and offline bookshops and at oreilly.de.

With React Native, a solid open source project for the cross-platform development of native apps has been available since 2015. Introduced by Facebook, it is now being further developed by some well-known companies and used for popular apps such as Airbnb, Skype, Tesla and Instagram (here for the official showcase) This article names eight reasons why the React Native framework is an attractive approach to app development.

1. A code base - not just for Android and iOS

Okay, of course we assume this for a cross-platform framework. Apps that are programmed for Android and iOS with React Native can largely fall back on the same code and be developed in parallel. If necessary - for example because of the different UI guidelines on both platforms - specific code for Android or iOS can be implemented seamlessly. And because JavaScript is programmed, parts of the business logic can be reused in web projects without specific code for the app.

2. Attractive and solid thanks to JavaScript and React

In React Native, JavaScript is used for programming, which makes the framework relatively easy to access for web developers, among others, because they do not have to learn a new programming language. In addition, React Native benefits from the declarative programming model in React, which offers an elegant and productive approach to creating user interfaces. This advantage is one reason for the growing popularity of React Native in recent years. With more than 60,000 stars, React Native is in the top 15 popular projects on github. And anyone who has already implemented web projects with React will be able to get started with app development with React Native quickly and without great effort.

3. Real native apps

React Native creates high-performance apps with native UI elements for Android and iOS. As expected, a button is displayed as a real button in the iOS app and in the Android version. This is a great advantage over hybrid frameworks such as Cordova and Ionic, whose application code is executed in a WebView. UI elements are only simulated there with HTML and CSS, which can have a negative effect on the appearance of the app. React Native also enables fluid animations - a fact that ensures a good user experience in an app.

4. High productivity through fast response times

If you have changed the code of a native app so far, it has to be recompiled every time. Before tests can be carried out on the smartphone, it takes at least a few seconds for an Android app and often even more time for an iOS project (not to mention the frequently reported crashes of XCode). Most programmers are probably aware that this can have a negative impact on their productivity and can be a test of their composure. In contrast, when programming with React Native, every change to the code is visible almost immediately in the app - thanks to features such as Live Reload and Hot Reloading.

5. Active environment with many extensions and tools

React Native is being actively developed by many developers and several companies. There are many useful extensions and libraries available that, for example, implement UI components that are not directly offered by React Native. The start-up Expo deserves special mention, as it has some useful open-source tools for React Native. To give just one example: the Expo app, in combination with React Native, makes it possible to develop native apps for the iPhone without an Apple computer. In addition, developers can use any auxiliary library from the huge open source environment of JavaScript or Node.js.

6. Other platforms besides Android and iOS

I mentioned above that parts of the JavaScript code can also be used for web projects. However, there are additional platforms for which apps can be developed with React Native. These include B. Apple TV and Microsoft's Universal Windows Platform. The architecture and functionality of React and React Native even make it possible to implement applications in the promising field of virtual reality (see React VR). And the React Native Web project makes it possible to integrate app components into web applications, which Twitter makes use of, among others.

7. Native code can be embedded

On the one hand, native code for Android and iOS can be embedded in React Native, so that native components of other projects or libraries can be reused. Conversely, it is possible to use React Native in app projects that were previously developed with the conventional approaches of Google or Apple. This makes it possible to implement new functionalities in these projects prototypically and across platforms with React Native and thus to continue the development in parallel for Android and iOS.

8. Easy entry with Expo Snack

The Expo Snack tool allows prototypical apps to be developed directly in the browser! This fantastic tool can be used to demonstrate apps or try out certain functionalities. In particular, nothing needs to be installed in order to gain initial experience with React Native. I recommend this interactive tutorial on React Native - create your first app there in five minutes. Getting started with app development is definitely not going to be any easier!

React Native is probably the only framework for cross-platform native app development that offers such a wealth of possibilities and functions. However, there are also restrictions in the framework that must be observed.

Some framework conditions require native code

There may be situations in which it is not possible to implement certain functionalities of an app with React Native. This could be a special control element for which there is (yet) no component in the framework. The React Native APIs also do not cover all device functions, so that certain sensor data cannot be queried. While native code can be embedded in these cases, it also means that at least one team member should be familiar with the native aspects of app development. This knowledge is also relevant if deeper errors in the code of an app have to be investigated, if downward compatibility has to be ensured in the future and if the app is to be published in the app stores.

The framework has not yet reached a stable version

Almost three years since its introduction, React Native is in active development with monthly releases of new versions. Occasionally there are changes to the framework, which means that APIs are changed or even removed. Nevertheless, React Native can already be used for app projects without major risks - many well-known companies are already providing evidence.

Erik Behrends is Professor of Computer Science at DHBW L├Ârrach (Baden-W├╝rttemberg Cooperative State University). There he mainly deals with issues of practical software development. He can be found on Twitter at @behrends.