Facebook has said that React Native builds on the principle of learn once, write everywhere, and that its goal is not to write cross-platform code.
NativeScript, which is pretty similar to ReactNative in the sense they both use Node.js, do offer the ability to share the same code over several platforms by writing platform specific code in files that uses native components that cannot be shared. It does that by simple naming convention, e.g foo.ios.js.
Since Facebook has not yet released their code for React Native for other platforms than iOS. Is this something they will likely support in the future?
I think there are far too many differences between Android, iOS and Web that it makes little sense to build common codebase for the whole projects. Android version will have not only native components, but also the logic of application screens and navigation will be different (iOS/Android/Web have all pretty different navigation patterns). Also there are many native components as part of the iOS/Android projects and they impact how application is started/debugged etc. so probably it is much better to keep Android and IOS parts as separate projects.
How I understand (and sympathise with) Facebok model:
Whenever there is a common functionality (in javascript) that you can separate out without dependency to react-native views, they will do it as separate component that can be reused across web/iOS/Android. For example they have relay library built for web Facebook. It abstracts away access to open-graph data on Facebook servers - the exact same relay library can be used in either environment as it has no dependencies to views, application logic and react as such.
I very much concur with that approach - the best way to do cross-platform is to follow the same practice:
So the Android and iOS and Web react-based application for the same "project" will always be three different codebases, but they might have quite a lot of shared javascript code in form of reused libraries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With