React Native - The good, the Bad and the Ugly.

React Native - The good, the Bad and the Ugly.

TL; DR An imperfect solution but still the best of a bad bunch.

React Native, another nail for my JavaScript hammer (Or is it?). Create mobile apps by writing JSX, a syntax extension for JavaScript. Sounds appealing to developers coming from a web background and living nightmare for backend C Sharp dev's. But what's the catch? There's a few, I'm coming up to 6 months on my mobile development journey and man have I had to assimilate a vast amount.

Config files, pipelines, Android development, IOS development, Android testing, IOS testing, PowerShell scripting, mobile UX/UI, TypeScript(although all web dev's should already be well on their way with this in 2021 in my opinion) and oh yeah React Native itself. That's just the tip of the iceberg. It's been eye opening and the most "I don't know what I don't know" I've experienced since I started my career. So, here's my "The good, the Bad and the Ugly" take on React Native.

The Good.

I get to write JavaScript, the one language to rule all. I already "know it" 😏 and because JavaScript is JIT(Just-In-Time) compiled we get the benefits of hot reloading. This makes at least the UI side of things a pleasure. Styling is different but familiar; it compiles tags that look like CSS to their native equivalent, margin is mostly going to behave like you would expect. Except you can't, for example, write margin: 15, 5; and have it fill tblr (top, bottom, left, right) like in web, you'll have to adjust each separately.

It's the most popular Cross Platform mobile framework used by software developers worldwide. So, you can count on Stack Overflow to save you for at least some of your issues, even finding react solutions that work for your React Native issue. At the time of writing this article React Native has fewer issues than the alternatives. Speaking of alternatives, why didn't we choose Flutter? Well It's still early days and with 5k+ issues on GitHub it's probably best to wait for it to mature.

Expo: you can get up and running very fast and with its browser support, you can see and debug your application using dev tools. Expo also provides an API for using the phone's camera, calendar, contacts and so on. All this comes with a downside I'll mention later.

The extra learning will add new mental models to your toolbox. You'll certainly not be bored with all the new challenges you'll face. It'll push you out of your comfort zone many times, and you'll be all the better for it. Because you'll have to write native code, you'll get that IOS development experience you might otherwise miss out on.

The Bad

Cross Platform still has the problem, although it's getting better, of having to write native modules. Want authentication? You've got to write it thrice! IOS, Android and React Native (just calling the modules in React Native at least). So, you've now had to learn how to write code and test it in three places, and the React Native bridge to make it all work. So, all the promise of "Learn once, write anywhere" is mostly UI related.

Pipelines, you'll need an OS X agent (that's just a mac mini sitting in a room somewhere), can't build IOS on a Windows or Linux agent. Need state management? Do I even need state management? Do I use Redux or MobX? you'll have to do your research and decide for yourself and that's really one of many situations where you'll go looking outside the "Framework" for solutions(If you come from Angular you're used to having all you need built in).

So back to the Expo downside, as soon as you must write native code, you'll have to eject from Expo which is irreversible. You’ll probably have to rewrite any of the Expo APIs you might have used to access the phones features and that might be a lot of refactoring. You won't miss what you've never had so just avoid it if you can.

The Ugly

No way around it, you'll have to dish out for a Mac and possibly dongles depending on what mac you get. XCode only runs on mac and it's the only way to develop and test iOS (Well played Apple you've now secured your place among mobile development). Oh, and we have the new M1 Mac's out now so no doubt you'll have to upgrade to those as Apple will stop supporting Intel in the near future.

I'm putting tutorials in the ugly section because this is where I found you can lose a lot of time. If a tutorial is a couple of years old, it's nearly useless. React and React-Native evolve so fast you find most of what tutorials show you to be deprecated and you'll lose a lot of time trying to get their solution to work. The new way to build components is function based not class based which is great but if you learn function based, you'll still need to learn class based to be able to refactor any existing code you'll encounter.

Closing

Hey, you are still reading, good, my rant was the right length. This was not an exhaustive list by any means and 6 months is a very short time to be doing anything and expect to have scratched the surface.

I like learning but React Native can feel like I'm adding an extra layer (learning three systems vs two). We did get the benefit of writing the UI once, so I guess that's where you must balance, is my application going to be more UI than anything else? In our case the answer is yes, for now. Would I use it to build an app if it was just for myself, maybe?

In my opinion native development is still the best if you want performance and need the native features of mobile (not just a WebView). The future though, in my opinion, is PWA(Progressive Web Apps) with near parity to native mobile performance and features(no support yet for Bluetooth for example), avoids the app store and their fees, and can be built without the overhead of all the extra learning and purchasing of hardware.

It'll be interesting to look back on this article in 6 months to a year to see how my opinions changed.



To view or add a comment, sign in

Others also viewed

Explore content categories