我已经开始学习React出于好奇,想知道React和React Native之间的区别-虽然不能找到一个满意的答案使用谷歌。React和React Native似乎有相同的格式。它们的语法完全不同吗?


当前回答

在Reactjs中,虚拟DOM用于在Reactjs中渲染浏览器代码,而在React Native中,本地api用于渲染移动设备中的组件。

用Reactjs开发的应用程序在UI中渲染HTML,而React Native使用JSX来渲染UI,这只是javascript。

其他回答

React Js是一个Javascript库,你可以使用React开发和运行更快的web应用程序。

React Native让你只使用JavaScript构建移动应用程序,它用于移动应用程序开发。更多信息请点击这里https://facebook.github.io/react-native/docs/getting-started.html

react是一个核心框架,旨在构建基于响应式模式的组件,你可以把它看作是MVC中的V,尽管我想说的是,react确实带来了不同的感觉,特别是如果你不太熟悉响应式的概念。

ReactNative是另一层,旨在为Android和iOS平台提供一套常见的组件。所以代码看起来基本上与ReactJS相同,因为它是ReactJS,但它是在移动平台上原生加载的。你也可以根据操作系统将更复杂的和平台相关的API与Java/Objective-C/Swift连接起来,并在React中使用它。

一个简单的比较应该是

反应Js

return(
    <div>
      <p>Hello World</p>
    </div>
)

反应本地

return(
    <View>
      <Text>Hello World</Text>
    </View>
)

React Native没有像div, p, h1等Html元素,相反,它有对移动设备有意义的组件。 详情见https://reactnative.dev/docs/components-and-apis

我们无法准确地比较它们。用例中存在差异。

(2018更新)


反应

React的主要关注点是Web开发。

React’s virtual DOM is faster than the conventional full refresh model, since the virtual DOM refreshes only parts of the page. You can reuse code components in React, saving you a lot of time. (You can in React Native too.) As a business: The rendering of your pages completely, from the server to the browser will improve the SEO of your web app. It improves the debugging speed making your developer’s life easier. You can use hybrid mobile app development, like Cordova or Ionic, to build mobile apps with React, but is more efficiently building mobile apps with React Native from many points.


反应本地

React的扩展,针对移动开发。

Its main focus is all about Mobile User Interfaces. iOS & Android are covered. Reusable React Native UI components & modules allow hybrid apps to render natively. No need to overhaul your old app. All you have to do is add React Native UI components into your existing app’s code, without having to rewrite. Doesn't use HTML to render the app. Provides alternative components that work in a similar way, so it wouldn't be hard to understand them. Because your code doesn’t get rendered in an HTML page, this also means you won’t be able to reuse any libraries you previously used with React that renders any kind of HTML, SVG or Canvas. React Native is not made from web elements and can’t be styled in the same way. Goodbye CSS Animations!


希望我帮到你了:)

React-Native是一个跨平台的应用程序,使用reactjs为所有平台(iOS, Android, Web, Windows, Mac, Linux)构建相同的代码。

实现上的区别在于reactjs使用HTML标记,而react-native使用react-native特定的组件。