Using React with React Native

Analysis of ReactJs and React Native

Minura Samaranayake
Geek Culture
7 min readMar 4, 2021

--

The web and mobile development world evolves by the day, and their applications become more powerful. Is it possible for these two departments to share their features with each other?

The answer eventually comes down to the users’ view. People peruse websites, but they just use mobile apps. Mobile apps are used actively by helping to carry out specific tasks while web apps are passively used providing a considerable amount of information.

It can be beneficial for a product facing the customer to exist both on the web and on the mobile phone. For example, Pizza Hut, Dominos, McDonald’s, etc. which are food delivery companies having applications on both web and mobile.

These applications may share pretty much the same features and functionalities. Integrating between web and mobile is not always easy. In this article, we will discuss more about sharing code between mobile and web apps using the most used web/mobile application development technologies, React and React Native.

Why React and React Native?

React and React Native are entirely different, despite the similar names. They serve various purposes, but combining them in your project will benefit you with a lot of advantages.

React is a library for frontend web development while React Native is a framework that facilitates cross-platform compatibility for mobile application development.

In React Native you simply write a React code but it acts as a bridge between JavaScript(JS) and mobile’s native properties. The added advantage of React Native is the cross-platform compatibility, which lets you run your app on both IOS and Android devices.

ReactJs

ReactJs is a JS library for creating User Interfaces (UI) that uses an easy way of rendering web pages, making them dynamic and responsive to users.

You can visit the following links if you want to move straight into development with React:

Get started with React

React documentation

React repository on Github to contribute to its development or to dive deeper.

Stack Overflow to find answers for the most popular or very specific questions

React tutorials for practicals

To learn about ReactJs visit reactjs.org

React Native

After two years of the release of React, Facebook created React Native. While the React library is developed for creating web UIs, React Native is a hybrid app-development framework for iOS and Android that allows you to reuse up to 95% of code.

If you want to start development with React Native, check these several useful links.

Get started with React Native

Set up the development environment

Visit React Native Github repository

React vs React Native

As far as we know up to now, both of these are very similar in nature but there are some major demarcations between them.

Technology

React renders code using the Virtual DOM

React Native is a bridge framework that runs components and features using native APIs.

React Native doesn’t use HTML, instead has its own syntax (e.g. <Text> instead of <p> and <View> instead of <div>).

React Native also provides an animation library and styles UI components using CSS-in-JS rather than standard CSS.

Navigation (Routing)

When routing between pages in React apps, it uses external libraries (such as react-router) to develop its navigation features and smooth transitions among pages.

In React Native, building UI is a lot less heckle.

React Native provides its own navigator component.

If your React Native app isn’t much complex you won’t need any external libraries

Platform-Specific Code

Unlike React, React Native tackles the need to write platform-specific code and create apps that conform to platform-specific UI and UX guidelines.

React Native doesn’t require the organization of components in separate folders. Instead, it offers different approaches to build cross-platform apps with higher efficiency.

Converting from React web to React Native

If you want to convert your React-based web app into a mobile app for both IOS and Android devices, React Native is the ideal choice. You can always revert a React Native app into a web app.

However, bear in mind that in order for the process to run smoothly, you’ll need a specialized team of developers who are familiar with React and React Native. It won’t suffice if you’re only good at one.

Sharing the code between web and mobile is not always easy. Since both React and React Native use JS, the app’s root components and logic are similar. You need to know platform-specific components in order to convert from React to React Native and it requires some knowledge in bridging native code. Sharing a codebase entails more than just reusing code. The process of porting React/React Native can sometimes be incredibly complicated, and it’s often easier to create web and mobile apps separately. It depends entirely on the type of app you’re making and the features you want to include.

Compatibility Issues

This is just another explanation why you need a React Native-experienced development team. Some component libraries and debugging tools can necessitate extra attention, slowing down the entire method.

Scalability

When it comes to app’s architecture, some careful planning is needed. Some choices should be made correctly at the very beginning, so if you are planning to develop your web and mobile apps at the same time a strategy in the long run should be implemented.

Instead of converting between React and React Native, it’s often easier to start from scratch with libraries like React Native for Web or ReactXP.

Sharing the Code

The primary difference between the frameworks isn’t necessarily using different APIs to achieve the same features. The presentation of the UI and the flow of the UX make a huge difference.

However, variations in APIs and UI/UX do not prevent code sharing between platforms. The Render Props pattern helps us to keep platform-specific primitive components like <views> and <divs> separate from component business logic, enabling us to share a lot of code across platforms.

For more information on code sharing techniques refer to “Sharing Code Between React Web and React Native Applications”.

ReactJS and React Native Apps

Companies that have already deployed React or React Native have done so for a number of reasons. Apart from Facebook, these are the most notable early adopters.

Photo by CardMapr on Unsplash

Netflix which adopted ReactJS in 2015, is now using it together with Gibbon, a rendering layer. Netflix preferred React at the time because of its one-way-ticket data flow model and declarative programming approach.

Instagram decided to develop a website, a one-page app, that would encourage web users to use the social network as well. And ReactJS seemed to be the best choice for this mission. The web app was well-designed in UI and UX as well. Now both web and mobile platforms are developed with React

Uber developed a mobile dashboard for selecting meals and restaurants with React Native components and added useful features including push notifications. This made ordering food via UberEats quick and convenient. The main idea behind creating the platform was to join three types of participants: restaurants, drivers, and clients. The framework capacity helped them scale up and grow the service.

Khan Academy is one of the biggest online education platforms. ReactJS is used extensively in it. The framework was chosen by Khan Academy to develop its eLearning portal because it would prevent unnecessary page reforming while replacing its elements smoothly and efficiently.

Bloomberg’s new mobile app for iOS and Android gives users a simple, interactive experience with simple-to-access personalized content, videos, and live feeds featured across Bloomberg’s Media. The online magazine chose React Native when developing its mobile app.

Airbnb decided to switch to React due to its reusable components, simple code refraction, and iteration. Now it’s used in internal structures of the company’s mobile app and webpage.

Conclusion

So far, we’ve gone through the differences between React and React Native, clarified the advantages and drawbacks of the latter, code sharing between the two, and shown examples of its use.

Given how many businesses have embraced it, the React platform is extremely innovative in terms of performance.

While other frameworks concentrate on improving UI in terms of software performance, React Native aims to revolutionize the way apps connect with software and hardware. ReactJS, on the other hand, has developed from a simple troubleshooting concept into a solution that can greatly reduce web development effort and improve performance. And the react community keeps improving.

When should you consider React Native?

When you want to build an app that works both on web and mobile. While developing with React and React Native is not a complete single-codebase solution, it is still one of the most efficient ways to create a cross-platform product due to the many similarities between the two tech stacks.

When you want to convert your web app to a mobile app. You’re still however going to need a development team that’s proficient in both React and React Native. Knowing only one of them won’t be enough.

When you want to develop a mobile app for both Android and iOS. React Native is a framework that could render native UI components on both mobile platforms, so you don’t need to write and maintain two separate codebases.

If you want to learn more about React from a business perspective or compare it with other similar technologies, read “React Web Development: A Practical Guide for CTOs”.

--

--

Minura Samaranayake
Minura Samaranayake

Written by Minura Samaranayake

Tech Enthusiast | Reading for Masters in Electrical Engineering | South Dakota State University | Department of Electrical and Computer Engineering