React Native: single code for Web, Android and iOS?

React Ionic openGeeksLab

React Native: single code for Web, Android and iOS? 

ReactNative openGeeksLab 

Writing code for several platforms is a very difficult. Programmers know it, and the last twenty years, the idea of “universal framework” is embodied in different technologies. Starting from Java and ending with PhoneGap, all developers wanted “write once, run anywhere”. But nothing happened.

And then Facebook made ReactJS, for repairing own chat. And it happened. The idea of assembly of interface from JavaScript “cubes” was so good that Facebook ported framework to mobile platforms, making at first React Native for iOS, and six months later for Android too.

 

The long-standing dream: write once, run anywhere

Fifteen years ago, the word “program” was synonym with “program for Windows”, the vast majority of computers ran on Windows, programs were created under concrete platforms and cross-platform decisions were rather a funny thing, than by a necessity.

And then a few things happened. Mac has grown in popularity, purchase and rental of software was simplified. Everyone started to use programs, not just “computer people”. And suddenly an old slogan “write once, run anywhere” has become very popular. All companies needed cross-platform apps.

 

React brings an adaptive design from web to mobile

Facebook presented React Native in 2015. At first glance, nothing new: JavaScript, from which you can create a “native” UI elements as on iOS, and on Android.

Using React, interface typeset semantically as on the Web. Rather than manipulate elements of the interface iOS or Android, the designer creates the interface of the logical component, “screen”, “header”, “list”, “button”. And then a few lines of code convert component “progress” in the set of HTML tags for the Web, ProgressBarAndroid for android and ProgressViewIOS for ios.

This approach is very convenient: interface typeset of universal blocks, and then finalized for each platform only where it is really necessary.

 

How it looks in practice?

First of all I want to note a small number of interface elements that are available “out of the box”. It’s easy to “wrap” any native element, but it will require knowledge of java, objective-c, or swift. The alternative – to use one of the hundreds of enthusiasts created items available on github. But open source is a very specific – sometimes problems from carelessly written elements more than if you do them yourself.

React Ionic openGeeksLab 

Conclusion

React has a number of advantages: web as one of the platforms, extremely popular JavaScript and node.js, free of charge, Facebook support and “hot reloading” out of the box.

We can say that now React Native can be used for rapid prototyping of mobile versions of your web applications. And if you have already written a web application on ReactJS, the transfer rate significantly increases. Creating complex applications with the publication in stores already possible, you can see it in the gallery. But be prepared for the fact that the final “bringing to mind” will be delayed and will require to go into Java and Objective-C.