If you haven't heard the React Native hype train yet, you will: it's probably the only thing that's noisier than the Caltrain at 6am. However, in my several months of React Native dev, I've learned the painful lesson that React Native is still at least several years away from being useful for anything but the most trivial of apps. My next stop: progressive web apps, and if that doesn't work out, I'm going back to Cordova. Here's why.
Numerous npm Modules Don't Work
The fact that you're writing plain-old JS is what drew me to React Native in the first place. However, what drew me to JS in the first place was easy code sharing and a rich ecosystem of high quality modules. Unfortunately, React Native is a distinct JS environment with its own idiosyncracies. This leaves you to fend for yourself in getting your favorite npm modules to behave. Here's a list of a few npm modules that I've run into issues with:
These issues are mostly due to React Native's lack of a global
environment, which causes a great deal of headache. I can't fault React Native
for that, it's a legitimate design decision because React Native doesn't run
You Need To Know Native, React, and React Native
One workaround I've seen for RN's quirks is
just wrapping native Java libraries and exposing them in JS.
Unfortunately, in order to do things like this for cross-platform apps, you
need to have experience with Java and Android dev
(and/or iOS, if you're still into that sort of thing). To include native
extension like, say, a wrapper around the Java version of analytics.js, you need
npm install a package and then make some changes to RN's Java code.
Naturally, the Java code changes you need to make have changed rapidly over
the course of RN's development, so while
other projects' are often out-of-date for long stretches of time.
React Native Apps Run In Least 3 Different Environments
So far, I've only run React Native apps 3 different ways:
react-native run-androidon an attached device
react-native run-androidon an attached device with remote debugging enabled
- Building the actual apk and installing it on my device
Each of these ways gives you a very different app, and it's quite common for
code to work as expected when using
react-native run-android but fail
miserably when you actually ship the apk. My personal favorite is
this issue. In this
case our app worked great with the first 2 ways, but we couldn't build the
apk because React Native clobbers your
NODE_ENV environment variable only
when you're actually building the apk.