williamle8300 williamle8300 - 1 year ago 80
React JSX Question

React Native & Android?

I'm contemplating on using React Native for a new web app. Is it possible to ship both iOS and Android apps using it?

I know that it's on the roadmap, but it's unclear to me whether it's going to be a separate open-source project (e.g., React Android vs React Native), or just one (e.g., React Native).

Answer Source

You can aim for about 80~99+% (depending on how much Android/iOS native views/modules you use eg. Do you have custom graphics code or low level TCP networking code; Those can only be done in native code; And expose as API to your JS code. The amount of the platform specific JS code is actually minimal. Plus you can also use platform check like if (Platform.OS === 'android'){} to solve that) of code reuse, which is pretty nice. Dropbox and other companies have done similiar project: using c++ to build a 'shared' component between iOS and Android project, while implement most of the UI code in native iOS(Objective-c or swift) and Android(java). But now you are doing C++ with Java and ObjectiveC or Swift, more language to master, more complexity and more brain juice went down the drain. And it probably took some super tough gymnastic move to make different native code work in both iOS and Android, plus debugging...

React Native just makes it a lot easier to write almost everything in JavaScript. But there is a catch, only about 80% of the JS code could be shared. In the foreseeable future, you still need to write 'platform-specific' JS code for Android and iOS version.

That's why FB said they aim for 'Learn once, code anywhere' instead of 'run' everywhere.

But it's still very nice other than code reuse(80+% code reuse is still a big improvement comparing to maintaining 2 entirely different version: Android and iOS ya?)

Cmd +R to refresh the app is a GREAT boost for development speed. Waiting for a big project to compile just make you felt you were dying inside ..

Declarative UI you get for free, because using React. This is another great plus! As you don't need to 'dig' into your specific UI code that often anymore. Data changed? Just 'flush' it and UI just update accordingly. No brain juice wasted.

I just ported my not so complicated Android React Native App to iOS. And it took me 3 days. The request for and iOS version for the App came as a rather abrupt and unplanned move. So could definitely be even faster had I built the Android with a plan for iOS too. Huge win:)

Another great benefit is able to do hot code push without going through the hellish 1 week app store review process. So no more, "YAY, our app is approved. Let's release. Oh Shiiit. Critical bug and our app keeps crashing(that's gonna keep happening for at least a week before your fix is live). And you have to beg Apple to speed up the process". This is possible because the major part of the code base would be written in JS and with tools like AppHub or CodePush, you could almost instantly deploy code to your users. This is conditionally allowed by Apple.

3.3.2 An Application may not download or install executable code. Interpreted code may only be used in an Application if all scripts, code and interpreters are packaged in the Application and not downloaded. The only exception to the foregoing is scripts and code downloaded and run by Apple's built-in WebKit framework, provided that such scripts and code do not change the primary purpose of the Application by providing features or functionality that are inconsistent with the intended and advertised purpose of the Application as submitted to the App Store.

Lastly, as a open source project, project longevity tends to be a concern. Not a issue for React Native. Internally used by(FB Ads Manager) and backed by FB(a dozen FB Engineers?) by Facebook, with close to 500 contributors and 25k Stars, React Native is full of live. Seeing is believing :) (https://github.com/facebook/react-native)


I realised that I am apparently a bit biased and only talked about the good stuffs about React Native. So do checkout https://productpains.com/product/react-native/ and Github issues to have a full picture. It's definitely not silver bullet. That being said, it satisfies most my use case and I couldn't see me use native iOS or Android anytime soon.

EDIT The Facebook F8 conference app release by Facebook (duh..) is 100% open source and they have a really nice tutorial to show you how you could have both iOS and Android native experience(90% as good as native ?), and at the same time, achieved 85% code re-use. check it out --> https://makeitopen.com