How does React Native actually do its work?

Dominic Imbuga
DevCNairobi
Published in
4 min readSep 21, 2021

If you are like me, a curious George , you will not be happy to just accepting what have been provided for you to use . You want to poke your nose into the hood and figure out how things work under the hood. How does React Native actually do its work?

You may have heard of hybrid mobile development and how react Native fits in the big picture in hybrid mobile development. The short story is about the problem the mobile app development community was challenged with , that of maintaining separate code bases for targeting both platforms because normally you have to build Android apps with Java or Kotlin and IOS apps with Swift or Objective-C !

This is a lot of code base to maintain, especially if you are a small company just starting out with no resources, you need to save on time and money. The question changed to , can we build under one code base and still target both platforms ?

React Native is one of the solutions to this challenge backed by Facebook, which is also behind React, you may not have realised it but Facebook's mobile app that you use to access your Facebook is built using React Native !

In this article we cover the salient features of hybrid mobile development and in particular how React Native works under the hood. You obviously have wondered how React Native uses JavaScript to build mobile apps that can run on both iOS and Android using the same code base, this is actually React Native's philosophy , ' Learn once write everywhere' !

Just so you know, this is a real app that is built using JavaScript but then React runs on your mobile device.React Native does not use web views so you get access to 100% of the native APIs using JavaScript, the app built therefore will not look different from apps built using the Native approach.

Along the way, I will introduce the salient features that make this possible. Just sufficient enough for us to understand how React Native works. This will really be comfortable if you have good knowledge of JavaScript as well as React, however no assumption made, let's dive in !

The idea here is to use Hybrid Development using JavaScript as a language of choice. This is where we understand that both Android and iOS have an already built-in JavaScript engine. Android has V8 and iOS has JavaScript Code which already is being used by the browsers in each of this two dominant platforms.

This means we have a virtual Machine already that understands JavaScript and is able to run JavaScript Code ! Why not build on top of that? React Native was born out of this what if question, it built a bridge into the Native environment.

This bridge taps in through the virtual Machine into the Native device capabilities and on top of this bridge we build React Native itself which is build with JavaScript and partly by Native code, that part is completely hidden from us.

We access the React Native itself by writing React Native application code on top of the React Native platform, this application code is completely written in JavaScript.

When you need to render your interface in either Android or iOS, both of them will access the native UI elements regardless of the platform then leverage them while rendering the UI for both platforms. This part is completely taken care of by the React Native platform.

We just live in the comfort of JavaScript environment and write our code Completely as if we were writing React Native Application and be able to leverage all of the native device capabilities.

If React Native is insufficient to meet your needs then you can always go native, meaning , injecting out of React Native environment then being able to that part of the app using native approaches.

But as you have realised in this article , React Native give you 100% access to native capabilities, this means you can do alot by just staying in the React Native environment except for very specific needs.

Congratulations for reading to the end.
Happy coding !

--

--