The future of mobile development with React Native

Le Truong Quoc Thang
5 min readMay 6, 2017

Many peoples are talking about React Native recently. Is it really the future of mobile development? And if it is, then is it for the future only, and not for now?

We all want to develop both Android, iOS, and Web by using a single mindset and a single language. We have tried many technologies/framework like PhoneGap, Xamarin, Cordova,.. but those are not what we really want. We just simply go back with the native way. But first, let’s take a look in the traditional ways (from now let’s call them traditional!).

1. Need to express the same idea on different languages

This is like we want to say I love you with a Thailand girl and we need to say ผมรักคุณ instead. It makes sense in love but doesn’t make any sense in software development. We have multiple codebases which basically for the same software, doing the same business logic. It basically violated the DRY rule (https://en.wikipedia.org/wiki/Don't_repeat_yourself).

I’m an Android Engineer. I used to learn to develop iOS and web apps. And I felt so boring because I need to learn the different languages and APIs set to just doing the same things. I want to show a list of users, let’s see how I did that

  • Android
UserListAdapter extend RecyclerView.Adapter<UserViewHolder> {    int getCount() { // Tell them how many items do we have}    UserViewHolder onCreateViewHolder() { // Return new view  }    void onBindViewHolder(...) { // Update UI for this view }
}
  • iOS
func numberOfSections(...) -> Int { // Tell them how many items do we have}func tableView(...) -> Int  { // Return new view  }func tableView(...> UITableViewCell { // Update UI for this view }

I’m 99% sure that iOS & Android platform engineers are copying the idea from others. But let’s forget about it first, it has nothing related to our topic here :)

Other than that, I also need to deal with the iOS and Android IDE layout system. Drag & drop UI elements are not easy like it should be.

This problem leads to a bunch of consequences, basically, we need to do everything twice or more:

  • Develop a feature need to be done twice, on both platform
  • QAs and testers need to test every feature twice.
  • Engineers need to fix a bug twice.
  • Behaviors between Android, iOS, web app will likely be different because it’s done by different engineers.
  • … many more which you will see in your products.

2. Compilation time is f***ing long.

For large projects (many features, millions of users) it should be around 2–3 mins (applied all optimizations we knew). It’s sometimes enough for me to forgot what I just have done to verify. 30 times compilation can cost us 1 hour as well, imagine what can we do with our girlfriend in that 1 hour, yes it inside the section title above.

3. No standard way to do the standard things

I’ve been working in 3 companies. To show a list of items, people both have different ways. One used MVVM, the other one used MVP and the current one going with Clean architecture. There is nothing wrong here, it’s just hard to everyone to look at other's code and understand what the hell is going on.

The future

There are many more problems. But let’s cut that session here first. Now let’s think about how can we solve them?

The first problem, imagine that there are iOS and Android guys to help us. All we need to do is we need to tell them what is the idea, then they will handle the implementation details for us. Problem solved!

This is what we currently have, our business logic is coupled with our platform logic:

With React Native, we can implement that business logic one time in JS side without touching any platform logic. It means that all the UI, UX user sees in their phone is platform-specific.

The second problem, the only way to solve it is to not compile! Can we do that? Can, by the interpreter.

Third but not last problem, life should be simpler and easier by React & Redux mindset.

More details, please!

We can solve all the problems above by using React Native. Take a look if you haven’t done so: https://facebook.github.io/react-native/

The big idea behind React Native is to learn once, write anywhere.

What does it mean? It means we just need to learn once and use that syntax to write for both Android, iOS, Web and even in UWP (if it still there). React Native will build the platform which is the iOS and Android guys above. Also, they use Java Script, the compilation problem suddenly solved! But the biggest change here is actually about mindset, how can we build a scalable app. Short answer: Components with state & props. Long answer: https://facebook.github.io/react/docs/thinking-in-react.html

Shut up and show me the code!

First, let’s take a look at the todo app. See if it can blow your mind: http://www.reactnativeexpress.com/

It seems like React Native is not the future of Mobile development, because it’s now, we can

We will discuss more on the further posts!

More document:

https://facebook.github.io/react/

--

--