Technological difference between react-native and

2020-07-27 02:40发布

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

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?

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)?

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.

2条回答
欢心
2楼-- · 2020-07-27 03:02

Does "React-Native" also create webview?

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.

This is mentioned on the 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.

And explained in more detail in 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.

查看更多
三岁会撩人
3楼-- · 2020-07-27 03:04

difference between react native and cordova ?

1.What is..

React Native:

React Native is based on React (a JavaScript framework) to design apps UI using JavaScript. It supports both Android and iOS to develop hybrid apps. Basically, React Native apps don’t use WebViews to render the app UI as in Cordova. A JavaScript interpreter is embedded to run only the JS code of the app.

Cordova:

Cordova is another open source JavaScript framework to design hybrid apps. Cordova apps use WebViews to render the user interface of the app. Cordova also allows developers to use latest web technologies like HTML5, JS, etc. to design apps for Android, iOS, and Windows.

2.Performance..

React Native:- Apps developed using React Native are faster than Cordova apps but slower than native ones.

Cordova:- Cordova apps are just Webviews which makes them sluggish and less responsive.

3.Supported Platforms..

React Native:- Android and iOS.

Cordova:- Android, iOS and Microsoft UWP.

4.Interaction with device core components..

React-Native:-React Native renders the UI written in HTML as native components which make the app interaction with the core device components faster.

Cordova:-Interaction with core device components is slower as compared to React Native apps.

5.Maturity..

React Native:-React Native is less mature than Cordova in terms of the number of available plugins.

Cordova:-Cordova is more stable than React Native.

6.Backward compatibility..

React Native:-Little support for old platforms. React Native doesn’t support iOS 7.

Cordova:-Better support for old platforms.

7.Portability..

React Native:-In React Native, there is a less code reuse as compared to Cordova. You have to almost reimplement code for different platforms.

Cordova:-Apache Cordova code written for one platform can be easily ported to a different platform without much of any headaches.

8.Debugging..

React Native:-The UI of a React Native app is debugged in the application itself and the JavaScript is debugged in the Chrome Developer Console. While debugging a React native app, the device only needs to be connected for the very first time only. After that, the debugging process can be done over a LAN. Also, debugging of React Native apps is simpler and easier than debugging of Cordova apps.

Cordova:-In Cordova apps, the UI and JavaScript are debugged in the Chrome Developer Console. While debugging a Cordova app, your device needs to be connected to the system.

9.When to use..

React Native:-Use React Native when you want to develop cross-platform apps with a more native feel and faster performance.

Cordova:-Cordova is best suited when you want to quickly convert your web application into a cross-platform but it comes with a cost of less native feel and slow performance.

I Think this answer is very helpful for you. Thankyou..

查看更多
登录 后发表回答