React platforms, what can you do? You have to

React Native: Asking the real questions.At the time of writing this, Facebook’s little baby React Native is almost 3 years old. Now, don’t get me wrong, in tech-years, that’s like puberty. Facebook made React Native public in March 2015, since then there has been a total of 12,506 commits in 57 branches by 1573 contributors till date. It’s also backed by tech giants like Microsoft and Samsung. Okay, that’s all well and good, but why should you bother if you already know Java/Swift or whatever language is that you speak. Can you trust React Native to your application? Can you actually cut development cost? What about the longevity of your app? Native languages, are they going to stay? Let’s get to it then.How is it better than native Android/iOS languages?First, let’s see what these native languages are good at shall we? They have access to all the functionalities and APIs their platform offers. They’re maintained by their respective parent companies like Google/Apple, which means updates will be mostly backwards compatible and porting the code to newer standards will be completely supported. Sweet, so your app will be safe in the long run and since these are strict languages it’s easier to detect errors as well. They’re also well documented, it’s easy to find a reference or get sample code. Moving on to third-party library support, there are tons of libraries for both Android and iOS.After all these features we talked about, at the end of the day if you need an app which can run on all platforms, what can you do? You have to develop your apps one by one, writing the same logic in different languages because native languages differ a lot and there’s virtually zero percent chance you can share the same code. React Native, on the other hand, converts your JS into platform specific components when it’s compiled, so the end result is same as that of native languages. It also provides APIs to enable most of the features of OS.  Most mobile apps have two parts, one server-side logic and on-device logic, former is mostly platform independent, why not make the later cross-platform as well!When it comes to custom UI design and network communication, React Native does a far better job than native languages themselves. It brings all the goodness of web development and merges seamlessly with native mobile development.Let compare a couple of common app requirements (with Java), so you can get a better picture.REST APIsLanguages like Java have a specific way of handling server communication using REST APIs. First, you decide on which library you want to use (because somehow the inbuilt one doesn’t always cut it). It’s easy to get lost in the realm of REST libraries, there are so many. Let’s say we picked one: Retrofit. Now, you’ll need an interface class which handles all your API calls:Let’s create a modal class, this has to match the response of the API. If the API has 100 fields in its response there’ll be 100 variables plus their getters and setters. If the API returns multiple kinds of response depending on the request… Well, more modals.Finally, you’re ready to make that API call. This is where you initialize everything you just created and hit the API.Now you have the response in your modal object. Let’s see how this is done in React Native. Since JS doesn’t require you to specify a datatype for a variable explicitly this process becomes a lot easier.The response is usually a JSON object. The ‘JS’ in ‘JSON’ stands for JavaScript, need I say more? You can store and use it as it is. That’s it!Custom UILet’s say the design of our app has buttons with rounded edges. In Android, you’ll start by making a custom XML with shapes and colours that match the button’s designThen you have to apply it as the background of the button you wish to customise.That’s a lot of code just to make a button with rounded corners. Let’s check out the RN code for the same:See what I mean? Is it really easy as they say it is?Yes, and no. React Native is based on JavaScript, unlike Java/Swift, it’s not a strict language. Some might enjoy the freedom while others tiptoe to avoid hidden errors. If you come from a web development background like me, you’ll probably be in the first group. Every developer will have to learn JavaScript at one point, so you might as well do it now.Introducing Expo: Another reason to love React NativeExpo is a set of tools which makes setting up and deploying a React Native app as simple as few lines of commands. It provides a set of components you can use, which are not already available in React Native’s arsenal so that you don’t have to know any native languages to complete a fairly advanced cross-platform application. Expo also has an app store – so you can distribute your app, a host app – which helps you run your project, server-side compiling – so you don’t need a mac to take builds for iPhones, ability to eject – which lets you edit native code if need be, and so much more. If you’re a developer, seeing your code changes reflect on both iPhone and Android devices in real-time is pretty awesome! React Native documentation has clearly mentioned the steps to get started with Expo (create-react-native-app) and also the regular method without Expo (react-native init).Let’s wrap upI don’t see Facebook (or other backers) abandoning React Native at any time in the foreseeable future. What does that mean? You can rest assured that your app will be supported and updated. With more companies starting to support development, React Native is spreading to more platforms like Windows and Tizen. It’s not very far from completing the prophecy – “Write once, use everywhere”