React-native和Cordova之间的技术差异 [英] Technological difference between react-native and cordova

查看:339
本文介绍了React-native和Cordova之间的技术差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

What is the technological difference between "react-native" and "Apache Cordova"?

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

I have been working with Cordova for a while now and the way it works is, it creates a webview (a headless browser) and runs the application inside of it with various API access. I have been wondering if same is true for "react-native". Does "react-native" also create webview? or does it convert javascript code to native code?

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

If it creates a "webview" like Cordova, then what is the difference between a "Cordova + React" app and a "react-native" app (excluding the native-components that are provided by react-native)?

我知道这里已经有此类问题的答案:电话差距与React Native .但是我的问题有点不同.谢谢.

I know there is already an answer to this type of question here: Phone gap vs React Native. But my question is a bit different. Thank you.

推荐答案

"React-Native"是否还会创建Web视图?

Does "React-Native" also create webview?

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

No. React Native is an abstraction to write native User Interfaces for Android and IOS. Your Javascript code runs in a Javascript runtime on the OS, but the UI is rendered as native components. This makes it very different than Cordova/PhoneGap.

React Native网页中提及:

本地组件

使用React Native,您可以使用标准平台 组件,例如iOS上的UITabBar和Android上的Drawer.这给 您的应用程序与平台其余部分保持一致的外观 生态系统,并保持较高的质量标准.这些组件很容易 通过与他们的React组件相对应的功能集成到您的应用中, 例如TabBarIOS和DrawerLayoutAndroid.

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.

,并在

由于React组件只是纯的,无副作用的函数,因此 在任何时间返回我们的视图,我们永远不需要 从我们的基础渲染视图实现中读取,以便 写给它.在浏览器环境中,React是非阻塞的 尊重DOM,但是React的优点在于它是抽象的, 没有与DOM紧密耦合. React可以包装任何命令式视图 系统,例如iOS上的UIKit.

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.

因此,这意味着通过一些工作,我们可以使其完全相同 GitHub上的React可以支持真正的本机移动应用程序.这 移动环境的唯一区别在于,它不是在运行 在浏览器中做出反应并渲染为div和span,我们在 在应用程序内部嵌入JavaScriptCore的实例,并渲染到 更高级的平台特定组件.

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之间的技术差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆