Avoid The Native In React Native

December 08, 2020

In times where there are multiple technologies like React Native and flutter, we often tend throw the word cross platform app loosely. I saw many react native applications that have been said to be cross platform until you start looking at the amount of platform specific codebase been written -

  • Cause certain UI components are platform specific like DrawerLayoutAndroid
  • There was a limitation within the React Native API, or performance limitation so native bridge had to be written

Try avoiding it as long as you can

Dropping some native code in React Native codebase brings multiple complexities -

  • Now anyone in future who needs to manage the codebase requires knowledge of native app development which means having understanding of three domains - Android, iOS and React Native 😦
  • Just shipped a new feature in Android, great now also ship it in iOS. Now you suddenly realise you're losing the very point of choosing React Native

Native can be hard to avoid for certain use-cases unfortunately

Yes we talked about what’s the right way to do but now let’s talk what’s practical.

  • Want to do some background syncing, well unfortunately that requires multi-threading. In JavaScript land multi-threading isn't possible. 😐
  • Need your app to talk to a native mobile feature but React Native doesn't support it, its time to write a native bridge which involves coding in native language along with javascript.

So how does one force themselves from not diving into native code -

Start of your green field app in expo cause it allows you to build app and test it on real device simultaneously. So no surprises of moving the app from emulator to real device. You loose this cool feature the moment you add native code since native code doesn’t compiles in run time.

But do you practice what you preach

Absolutely 🙂, I have been building a commercial B2B SaaS mobile app following the same development model. As a developer choose the easier path cause even that often ends up being lot more harder than you thought.

Harsh Vardhan  is a React Native consultant aiming to streamline and accelerate your React Native App development.