Note: Only been dabbling with React Native for about 7 weeks and only for Android. So think of this more as a newbie's thoughts on React Native for Android.
For the past 7 weeks I've been creating an Android app1 for a friend, and chose to use React Native. With the app now complete, here are my thoughts about using React Native for Android dev.
Let's start with the good stuff
Zero to Something—fast!
If you've used React before, you'll be able to translate most of the concepts across. You're still dealing with components. Your mental model of how to structure the "pages" of your app is almost the same. You can also leverage your CSS knowledge as that's how everything is styled. Being able to re-use all this knowledge means there are not a lot of new concepts to learn, allowing you to start creating your app almost immediately.
Fast dev loop
The dev loop is really nice to work with. Turn on hot reloading and it's basically the same as having
watch on the app, it auto-reloads after you save. If the change is bigger, shake the phone to do a full reload. Depending on the size/complexity of the app, reload times my differ—for me the hot reload took roughly 2-3 seconds and the full reload around 5-10 seconds. This fast feedback loop was great, especially when tweaking the UI.
When you make a mistake in your code, the error messages are usually really helpful. It tells you why it failed, generally shows the line that caused the error, and sometimes even how to fix the error. The stack trace is also included for any deep diving if required.
Bonus: if you tap on the stack trace, it'll open the file at that line in your editor!
The not so great stuff
When things get complicated
React Native provides many core native components/features (eg.
ScrollView, TextInput, ImageView). However, if you need something that isn't part of React Native, you have the choice of finding a library that someone else has written or writing your own (Native Modules, Native UI Components).
I didn't want to reinvent the wheel (plus needed to complete the app asap) so looked for existing libraries. Despite finding a library that matched each of my needs, it wasn't without struggle and frustration. Some of the libraries were outdated or required a specific version of React Native to work.
When the libraries worked it was awesome. However, when they didn't it often meant investing a lot time to figure out why. Was it broken because it wasn't linked properly, or was I using it wrong, or maybe it wasn't the right library? After confirming a library was broken it was then a question of find another library (and hope it works) or write my own.
Linking libraries is supposed to be super simple, just run the command:
However, that command never worked for me. Instead, I needed to manually link the libraries. In fact, running the command actually broke some links; I believe this is because the libraries were old, or didn't expose the correct information.
This is potentially a non-issue (maybe upgrading my version of React Native will help?), but not sure how the command will handle libraries that don't expose the correct information.
Also, the docs seem more geared towards iOS, probably because React Native was available on iOS first.
Overall, working with React Native was quite enjoyable. Although there were many super frustrating times, I feel a lot of it is because I know enough to be annoyed, but not enough to fix my problems.
In my opinion, the weakest and most frustrating part of React Native is the lack of good 3rd party libraries—imagine writing a node app with only a super restricted selection of reliable and maintained packages.
Despite this, for future mobile projects, I would definitely consider using React Native. Especially since I would like to learn how to write my own native module and make the app compatible for both Android and iOS.