The Skeptic’s Guide To React Native
I’ve been fielding a few questions lately from friends, colleagues, and clients. People are rightfully skeptical with the hype around React Native. Here’s a low-down of what I’ve been hearing.
It does what?!? Run that by me again?
So get this. You take some:
- Javascript
- Something that looks like HTML
- Styles (Javascript in a CSS dress)
Then don’t compile it.
Instead, throw it into a single-threaded Javascript interpreted environment on a mobile device and see what happens.
On paper, this is a clown car and should not work.
SPOILER: It does. Extremely well.
Why do you actually WANT to do this?
Here are my top 3 reasons:
- Cross platform.
- Amazing development experience.
- I can still use Obj-C, Swift &&|| Java too.
React Native and React. Same Thing?
No. Spooky amount of overlap though.
React is for browsers. React Native is for iOS & Android.
React slings DOM elements. React Native pushes native platform views.
React as a “concept” is about constructing views. People have even ported these practices to rendering things for a console.
But there’s a convergence going on though. Especially as of RN 0.18. Is React now called React DOM? I don’t know. Lines are getting blurry.
Is it active?
Very much so. 511 contributors as of this writing. Many new features, fixes, and discussions every version. It’s incredibly healthy.
There is a great community newsletter, twitter action with #reactnative, and 3rd-party components sites.
Is this the part where you tell me its fast?
Yes. Don’t go mining bitcoins, but people are doing some crazy things with it. Fire up the FPS monitor and you’ll see it pinned to 60 most of the time.
Javascript is not the villain you think it is. Running in JavaScriptCore, code flies.
Is it multi-threaded?
No. Well, kinda.
There’s 3+ “threads”. You get to use one directly. That’ll be running your Javascript. Everything is pretty much async in Javascript land, so you’ll rarely be blocked.
And the Javascript thread isn’t the main/ui thread either.
This is big news for Android developers, who have to do all kinds of crazy backflips to stay off the main thread. — Darin Wilson
How often is it updated?
New releases are 3–4 weeks apart. Release candidates often ship shortly after a new release is cut.
What’s the development flow like?
It’s astonishing. Type some code. Hit save. App gets auto-reloaded. Instantly.
You can run the app on multiple devices and emulators/simulators simultaneously. Hot-reloading is incoming soon.
Use your own editor. No need to use Xcode (other than launching) or Android Studio.
Now I need to be an expert in iOS AND Android?
Surprisingly, no.
Sure it helps. But for the most part, you’ll be interfacing with React components (and building your own): views, labels, lists, scroll views, etc. They turn into real native components indirectly.
In my opinion, a background in Javascript will actually help more.
Debugging is probably fun.
That’s not a question.
When your app bombs, you’re presented with a great stack trace showing you line numbers and such. With the right editors and environment variables, clicking on a line in the simulator opens the file in your editor.
Then there’s Chrome debugging. Set a break point. Explore the scope chain. Trace variables. Or, like me, only use it for console.log() and still be happy.
There’s a built in profiler but you can also drop down to Instruments or systrace.
Cross platform? For realz? Cuz I’ve been lied to before.
Yes.
Unless you write native code or use platform-specific React Native components.
The overwhelming majority of your codebase will be portable. In fact, creating a brand new React Native app, sets you up to run on both platforms.
Are people writing libraries for React Native?
Are they ever! And many are cross-platform. You can even use some npmlibraries like lodash, moment.js, Ramda, Redux, and more.
What comes in the box?
Maps, lists, navigators, alerts, and lots more.
Are you going to make me write Javascript?
Yes. But a modern version (ES6/ES2015). Wait until you see destructuring, spreads, fat arrows, and more in action.
I know I know. It’s still no *insert better language here*.
Can I use things like CocoaPods?
Yes. You can bridge to existing code by writing some wrappers. You write these in Swift or Objective-C.
Is there a best way to build apps?
For bigger apps, definitely look into Dan Abramov’s Redux and Yassine Elouafi’s redux-saga (see my previous blog post </selfpromo>).
It’s still all really new, though. Tom Goldenberg (article) and James Ide(article) have written great posts recently about what works for them.
OK, so who is using it in production?
Of course Facebook is using it in places, but the list is growing!
What does it suck at?
I think most people would say view recycling, push notifications, running in background, not all platform components are wrapped, etc.
Android support is fairly new, but its velocity in feature parity is incredible right now. Here’s a good article on that.
Can I really live-patch my AppStore apps?
Yes.
Apple says they’re cool with this. AppHub, CodePush, and Exponent are doing this now and can help you bypass the #iosreviewtime on the AppStore.
How do I submit to the app store?
The same way you do now. You’re actually making APKs and IPAs. These are native apps.
Fastlane can help automate some of this.
Conclusion
For a little more insight, Marc Shilling has a beautiful write up describing his reservations and revelations stepping into this stack.
At Infinite Red, we keep hearing the same concerns about React Native. Do you? Do you have questions too? You can reach me on the land of tweets as @skellock. Press the ❤ below if you like computers or cats.