3 ms·
I agree with all of this, but I'd add that bridging RN to Native is not as scary as it sounds. Check out the code examples: https://facebook.github.io/react-na
by QualityReboot 8y ago
I agree with all of this, but I'd add that bridging RN to Native is not as scary as it sounds.
Check out the code examples: https://facebook.github.io/react-native/docs/native-modules-ios https://facebook.github.io/react-native/docs/native-modules-...
In practice, most of it is wrapping "RCT_EXPORT_METHOD" around native code and importing it into JS.
Even if you had to write half the app in native code (which you won't), you're still far ahead of having to write it all in native code on both platforms.
- laex 8y agoAgreed. Creating bridging modules aren't that complicated. For anyone interested, I've linked a sample of a bridging module from my open-source project, for both IOS and Android. See [0] & [1] The bridge creates an interface between an embedded webserver to react native. Things to note: 1. Always dispatch bridging methods to their own threads. On IOS you can do this via. dispatch_async. On Android, you can utilise native threads or some kind of task management library. I like Bolts [2]. 2. Always create bridging methods that resolve promises. This makes it easy to utilise async / await paradigm on the JS side. [0] Android: https://github.com/hemantasapkota/react-native-web-server/tree/master/android/app/src/main/java/com/reactnativewebserver/AppWebServer https://github.com/hemantasapkota/react-native-web-server/tr... [1] IOS: https://github.com/hemantasapkota/react-native-web-server/tree/master/ios/ReactNativeWebServer/AppWebServer https://github.com/hemantasapkota/react-native-web-server/tr... [2] Bolts: https://github.com/BoltsFramework/Bolts-Android https://github.com/BoltsFramework/Bolts-Android