将 React Native 用于 UI,但仍将原生 API 用于其他用途
Use ReactNative for UI but still use native API for other things
我尝试开发我的应用程序,该应用程序仅将 ReactNative 用于 UI 但仍将(在 Android 中)Activity/Fragment/Service 类 用于业务逻辑。 iOS 也一样,业务逻辑仍然使用 Controller 等。
但是当我在 Youtube 上搜索 Google 时,我找到的所有教程都只讲述了如何制作只有 UI 东西的应用程序,纯 ReactNative 代码。我的问题是:
是否可以仅使用 ReactNative 制作 UI 但仍继续使用原生 API 例如Activity/Fragment/Service (Android), Controller (iOS) 在我的移动项目中?
如果可以,怎么做?有什么好的教程(Android 和 iOS)?
根据 this article,我不建议对任何事情都使用本机模块 (Activity/Fragment/Service..)
The performance bottleneck often occurs when we move from one realm (native or javascript) to the other. In order to architect performant React Native apps, we must keep passes over the bridge to a minimum.
如果你有兴趣了解,this is how bridging works
是否可以如愿以偿?是的。
但是,如果您要拥有活动、服务和业务逻辑,那么您最好在本机中全部完成。
根据您的应用需求,react-native 是否适合您。如果您的应用高度硬件(蓝牙、加速度计等),需要高帧率性能(如游戏)或与其他应用大量交互应用程序(内容提供商)或设备系统(如警报管理器),那么我不建议使用它。否则,这是一个了不起的选择。
我尝试开发我的应用程序,该应用程序仅将 ReactNative 用于 UI 但仍将(在 Android 中)Activity/Fragment/Service 类 用于业务逻辑。 iOS 也一样,业务逻辑仍然使用 Controller 等。
但是当我在 Youtube 上搜索 Google 时,我找到的所有教程都只讲述了如何制作只有 UI 东西的应用程序,纯 ReactNative 代码。我的问题是:
是否可以仅使用 ReactNative 制作 UI 但仍继续使用原生 API 例如Activity/Fragment/Service (Android), Controller (iOS) 在我的移动项目中?
如果可以,怎么做?有什么好的教程(Android 和 iOS)?
根据 this article,我不建议对任何事情都使用本机模块 (Activity/Fragment/Service..)
The performance bottleneck often occurs when we move from one realm (native or javascript) to the other. In order to architect performant React Native apps, we must keep passes over the bridge to a minimum.
如果你有兴趣了解,this is how bridging works
是否可以如愿以偿?是的。 但是,如果您要拥有活动、服务和业务逻辑,那么您最好在本机中全部完成。
根据您的应用需求,react-native 是否适合您。如果您的应用高度硬件(蓝牙、加速度计等),需要高帧率性能(如游戏)或与其他应用大量交互应用程序(内容提供商)或设备系统(如警报管理器),那么我不建议使用它。否则,这是一个了不起的选择。