Facebook created React Native to build its mobile applications. The motivation to do so came from the fact that React for the Web was so successful. If React is such a good tool for UI development, and you need a native application, then why fight it? Just make React work with native mobile OS UI elements!
In this chapter, you'll be introduced to React Native and the motivations for using it to build native mobile web applications.
Earlier in this book, I introduced the notion of a render target—the thing that React components render to. The render target is abstract as far as the React programmer is concerned. For example, in React, the render target can be a string or it could be the DOM. This is why your components never directly interface with the render target, because you can never assume that it is what you think it is.
A mobile platform has UI widget libraries that developers can leverage to build apps for that platform. On Android, developers implement Java apps while on iOS developers implement Swift apps. If you want a functional mobile app, you're going to have to pick one. However, you'll need to learn both languages, as supporting only one of two major platforms isn't realistic for success.
For React developers, this isn't a problem. The same React components that you build work all over the place, even on mobile browsers! Having to learn two more programming languages to build and ship a mobile application is cost and time prohibitive. The simple solution to this is to introduce a new React that supports a new render target—native mobile UI widgets.
React Native uses a technique that makes asynchronous calls to the underlying mobile OS, which calls the native widget APIs. There's a JavaScript engine, and the React API is mostly the same as React for the Web. The difference is mostly with the target; instead of a DOM, there are asynchronous API calls. The concept is visualized here:
This obviously oversimplifies everything that's happening under the covers, but the basic ideas are as follows:
Much more on the history and the mechanics of React Native can be found here at https://code.facebook.com/posts/1014532261909640.
3.142.40.43