Skip to content

Latest commit

 

History

History
93 lines (53 loc) · 5.07 KB

1-Introduction.md

File metadata and controls

93 lines (53 loc) · 5.07 KB

Chapter 1 - Introduction

What is React Native?

React Native is a framework that allows you to build native mobile apps using JavaScript.


React Native is not about avoiding any native development, it’s more about boosting productivity and sharing business logic and practices among very different platforms. [1] .

Why the need for React Native?

  • reuse ideas and skills across platforms - Learn Once, Write Anywhere
  • make mobile developer experience as quick as that of a web developer
  • maintain one codebase instead of two for mobile project
  • lower the cost of hiring a mobile developer
  • increase the pool of mobile developers by lowering the cost of entry

Who is using React Native?

You can check Showcase page and React Native Apps GitHub pages for some of the apps built with React Native.

Some misconceptions about React Native

Is it for everybody and every case?

NO.

Read about the Airbnb experience with React Native [2] and the reasons they are moving away.

tl;dr

Some of the things that worked for Airbnb:
  • Cross-platform

    Most features that used React Native were able to achieve 95–100% shared code and 0.2% of files were platform-specific (.android.js/.ios.js).

  • Iteration speed

    While developing in React Native, we were able to reliably use hot reloading to test our changes on Android and iOS in just a second or two. (...) At best, native compilation times are 15 seconds but can be as high as 20 minutes for full builds.

  • Performance

    One of the largest concerns around React Native was its performance. However, in practice, this was rarely a problem. Most of our React Native screens feel as fluid as our native ones. Performance is often thought of in a single dimension. We frequently saw mobile engineers look at JS and think “slower than Java”. However, moving business logic and layout off of the main thread actually improves render performance in many cases.

  • Animations

    Thanks to the React Native Animated library, we were able to achieve jank-free animations and even interaction-driven animations such as scrolling parallax.

Some of the things that didn't work for Airbnb:
  • Performance

    However, the initialization and first-render time (outlined below) made React Native perform poorly for launch screens, deeplinks, and increased the TTI time while navigating between screens.

  • Immaturity

    React Native is less mature than Android or iOS. It is newer, highly ambitious, and moving extremely quickly.

  • JavaScriptCore inconsistencies

    ... it is executed on a JavaScriptCore environment. The following are consequences we encountered as a result:

    • iOS ships with its own JavaScriptCore out of the box. This meant that iOS was mostly consistent and not problematic for us.
    • Android doesn’t ship its own JavaScriptCore so React Native bundles its own. However, the one you get by default is ancient. As a result, we had to go out of our way to bundle a newer one.
    • While debugging, React Native attaches to a Chrome Developer Tools instance. This is great because it is a powerful debugger. However, once the debugger is attached, all JavaScript runs within Chrome’s V8 engine. This is fine 99.9% of the time.
  • Initialization Time

    Before React Native can render for the first time, you must initialize its runtime. Unfortunately, this takes several seconds for an app of our size, even on a high-end device. This made using React Native for launch screens nearly impossible.

    Also, have a look at the follow up by Charlie Cheever from Expo team [3].

Does it mean I don't need to know Java/Kotlin/Objective-C/Swift?

YES and NO.

What is Expo?

Expo is a free and open source toolchain built around React Native to help you build native iOS and Android projects using JavaScript and React.

Where to seek help

Resources

  1. Thoughts about React Native after a few months working with it.
  2. React Native at Airbnb.
  3. Should we use React Native?