When you should/shouldn't use React Native?
I have used React Native for 2 years for various apps. I have used it both at a company and as a freelancer so I have good knowledge of its pros and cons and how the development process goes. I have recently watched this video by "the TechLead":
I have also watched/read others refuting his argument. That's why in this article, I will try to explain both arguments as objectively as possible so you as an engineer/product owner can make an informed decision about whether or not you should use React Native.
Before you start, the first question should be Do you really need an app? if you only need basic CRUD then you might be better off using Progressive Web Apps. You should always consider that option before going into the hassle of developing an app. However, If you do need an app continue reading the rest of the article.
1. A single code base for both Android and iOS:
Often when React Native developers (or cross-platform developers in general) argue about why you should use React Native, they say that you only need to write the code once and it works on both platforms. This statement is both true and false depending on what the app does.
In React Native, you will often need to make modifications in the native code to make a feature work. For example, if you want to add push notifications, you will need to make different configurations in the native Andorid and iOS projects to make it work. That goes for many other features like using maps or camera. These configurations aren't always straight forward and they often take extra effort to make a feature work on both platforms. However, if you're making a simple app that only retrieves and shows data, then you will most probably write the code only once and it will run on both platforms with no issues. You can also use expo which abstracts the native code layer and offers many features out of the box, however, if you use expo you cannot use external libraries to add more features to the app.
What that means If your app is not simple enough to be written with expo, you're probably going to spend more time configuring libraries than coding. Unless you're willing to do that don't use React Native for apps that have much functionality that rely on the devices' hardware. For simple apps however, React Native will definitely save you time and effort.
2. How complex is the Design?
One important thing to consider is the design. React native uses JS which means that it is single-threaded. For the design, that means that the animations will freeze the entire app if done in the JS thread. However, there are ways to implement animations in the native layer and only fire the animation from the JS thread which means that you can still do smooth animations in React Native if you learn the correct way to do that.
Another problem regarding the design and the styling is that iOS and Android behave differently with the same style attributes. For example, shadows work on iOS by simply adding style attributes but for android, you need to install a library to add shadows to your Views. However, in most cases you implement the style only once and it works fine on both platforms.
A third issue is that Android and iOS have different UX. Android users for example are used to going to the previous screen or cancelling an action using the back button while iOS has no back button which means you will need to handle the back button action on android and add buttons to do those same actions for iOS.
What that means Depending on the design, you might still need to write different code to apply the same style in both Android and iOS. The code is not necessarily native but you will need to handle platform-specific behaviors nevertheless.
3. How much are you expecting to scale?
This is perhaps the most important question. What is your app's expected scale? according to the answer of that you will know how much you need to focus on the performance. If you're creating an app for a small audience or a prototype then it probably won't matter if you choose React Native or native iOS and Android. However, if your app is expected to have a huge number of users it means that you will need to consider performance. Let me tell you this: if you're concerned about performance then you will have to write native code eventually and probably a lot of it. React Native has many known performance issues and to fix them you have to get past the JS code and implement them natively.
What that means You will end up maintaining 3 frameworks instead of one to improve performance. However, if you're creating a prototype or an app that is not concerned with the best possible performance then React Native would be a good option.
Something that has always caused me a headache is managing the dependencies in React Native projects. Often, I would find two or more libraries that have conflicting versions of Maven dependencies to solve that I had to check the dependency tree and then manually change the versions of the android projects in the nodemodules to compatible versions. You also need to manage iOS dependencies as well either by using cocoa pods or manually adding the dependencies to the project. In addition to that, you have the nodemodules to manage. This has certainly caused me to waste a lot of time but then again, that wouldn't happen for simple projects where dependencies are few and it certainly won't happen if you use Expo.
5. What is the market state?
If you're a developer who's considering to learn React Native or a product owner who's considering which technology or what talent you need then this is a question that you have to answer.
As a developer you need to consider:
a. What the current market needs.
b. What is the cost of learning React Native for you? Learning React Native is a lot easier if you already know Js and it's even easier if you know ReactJs.
As a product owner you need to consider:
a. Are you making a prototype or a fully functional app? React native is usually faster for prototypes and MVPs but worse at scaling. Consider that in case your app scales, You can always switch from React Native to native once you have enough fund to hire separate iOS and Android teams.
b. What is the cost of hiring React Native Engineers vs iOS and Android Engineers? You can't really choose to use React Native if your market doesn't have React Native developers or if they cost more than iOS and Android Engineers.
There are no silver bullets, as a software engineer you have to make trade-offs all the time when choosing technologies. You should never dismiss a technology as "garbage" or praise a technology as if it's the Holy grail. React Native is no different, it has it's pros and cons and it's up to you to decide which trade-offs you are willing to make.