react-native 和 cordova 的技术差异

Technological difference between react-native and cordova

"react-native" 和 "Apache Cordova" 之间的技术区别是什么?

我使用 Cordova 已经有一段时间了,它的工作方式是,它创建一个 webview(无头浏览器)并在其中运行具有各种 API 访问权限的应用程序。我一直想知道 "react-native" 是否也是如此。 "react-native" 是否也创建 webview?还是将 javascript 代码转换为本机代码?

如果它创建了一个像 Cordova 的 "webview",那么 "Cordova + React" 应用程序和 "react-native" 应用程序之间有什么区别(不包括 react- 提供的本机组件)原生)?

我知道这里已经有此类问题的答案:。但我的问题有点不同。谢谢。

Does "React-Native" also create webview?

没有。 React Native 是为 Android 和 IOS 编写本机用户界面的抽象。您的 Javascript 代码在 OS 上的 Javascript 运行时中运行,但 UI 呈现为本机组件。这使得它与 Cordova/PhoneGap.

非常不同

这在 React Native webpage 中提到:

Native Components

With React Native, you can use the standard platform components such as UITabBar on iOS and Drawer on Android. This gives your app a consistent look and feel with the rest of the platform ecosystem, and keeps the quality bar high. These components are easily incorporated into your app using their React component counterparts, such as TabBarIOS and DrawerLayoutAndroid.

并在 this blog post 中进行了更详细的解释:

Since React components are just pure, side-effect-free functions that return what our views look like at any point in time, we never need to read from our underlying rendered view implementation in order to write to it. In the browser environment, React is non-blocking with respect to the DOM, but the beauty of React is that it is abstract and not tightly coupled to the DOM. React can wrap any imperative view system, like UIKit on iOS, for example.

So this means with a bit of work, we can make it so the exact same React that's on GitHub can power truly native mobile applications. The only difference in the mobile environment is that instead of running React in the browser and rendering to divs and spans, we run it in an embedded instance of JavaScriptCore inside our apps and render to higher-level platform-specific components.

react native 和 cordova 的区别?

1.What 是..

React Native:

React Native 基于 React(一个 JavaScript 框架)使用 JavaScript 设计应用 UI。它同时支持 Android 和 iOS 来开发混合应用程序。基本上,React Native 应用程序不会像在 Cordova 中那样使用 WebViews 来呈现应用程序 UI。 JavaScript 解释器仅嵌入到 运行 应用程序的 JS 代码。

科尔多瓦:

Cordova 是另一个用于设计混合应用程序的开源 JavaScript 框架。 Cordova 应用程序使用 WebView 呈现应用程序的用户界面。 Cordova 还允许开发人员使用最新的 Web 技术,如 HTML5、JS 等来为 Android、iOS 和 Windows 设计应用程序。

2.Performance..

反应本机:- 使用 React Native 开发的应用程序比 Cordova 应用程序快,但比原生应用程序慢。

科尔多瓦:- Cordova 应用只是 Webview,这使得它们运行缓慢且响应速度较慢。

3.Supported 平台..

React Native:- Android 和 iOS.

Cordova:- Android、iOS 和 Microsoft UWP。

4.Interaction 具有设备核心组件..

React-Native:-React Native 将 HTML 中编写的 UI 呈现为本机组件,这使得应用程序与核心设备组件的交互更快。

Cordova:-与 React Native 应用程序相比,与核心设备组件的交互速度较慢。

5.Maturity..

React Native:-就可用插件的数量而言,React Native 不如 Cordova 成熟。

Cordova:-Cordova 比 React Native 更稳定。

6.Backward 兼容性..

React Native:-对旧平台的支持很少。 React Native 不支持 iOS 7.

Cordova:-更好地支持旧平台。

7.Portability..

React Native:-在 React Native 中,与 Cordova 相比,代码重用较少。您几乎必须为不同的平台重新实现代码。

Cordova:- 为一个平台编写的 Apache Cordova 代码可以很容易地移植到不同的平台,没有太多麻烦。

8.Debugging..

React Native:-React Native 应用程序的 UI 在应用程序本身中调试,JavaScript 在 Chrome 开发人员控制台中调试。 在调试 React 本机应用程序时,设备只需要在第一次连接。之后,调试过程可以通过 LAN 完成。此外,React Native 应用程序的调试比 Cordova 应用程序的调试更简单、更容易。

Cordova:-在 Cordova 应用程序中,UI 和 JavaScript 在 Chrome 开发人员控制台中进行调试。 调试 Cordova 应用程序时,您的设备需要连接到系统。

9.When 使用..

React Native:- 当您想开发 cross-platform 具有更原生感觉和更快性能的应用程序时,请使用 React Native。

Cordova:-当您想将 Web 应用程序快速转换为 cross-platform 时,Cordova 最适合,但它的代价是原生感觉较差且性能较慢。

我认为这个答案对您很有帮助。谢谢..