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


当前回答

这里有一个很好的解释:

Reactjs是一个同时支持前端和服务器的JavaScript库。此外,它还可以用于为移动应用程序和网站创建用户界面。

React Native是一个跨平台的移动框架,使用Reactjs来构建应用程序和网站。React Native编译成本地应用程序组件,使程序员能够用JavaScript构建可以在不同平台(如Windows、Android、iOS)上运行的移动应用程序。

Reactjs can be described as a base derivative of React DOM, for the web platform while React Native is a base derivative in itself, which means that the syntax and workflow remain the same, but components alter. Reactjs, eventually, is a JavaScript library, which enables the programmer to create an engaging and high performing UI Layer while React Native is an entire framework for building cross-platform apps, be it web, iOS or Android. In Reactjs, virtual DOM is used to render browser code in Reactjs while in React Native, native APIs are used to render components in mobile. The apps developed with Reactjs renders HTML in UI while React Native uses JSX for rendering UI, which is nothing but javascript. CSS is used for creating styling in Reactjs while a stylesheet is used for styling in React Native. In Reactjs, the animation is possible, using CSS, just like web development while in React Native, an animated API is used for inducing animation across different components of the React Native application. If the need is to build a high performing, dynamic, and responsive UI for web interfaces, then Reactjs is the best option while if the need is to give mobile apps a truly native feeling, then React Native is the best option.

更多信息请点击:https://www.simform.com/reactjs-vs-reactnative/

其他回答

React是一个用于构建用户界面的JavaScript库。它用于重用UI组件。 React Native是一个JavaScript框架,用于为iOS和Android编写真实的原生渲染移动应用程序。 两者都是由facebook开发的,它们共享相同的生命周期方法。

首先是相似之处:React和React Native (RN)都是为了创建灵活的用户界面而设计的。这些框架有很多好处,但最基本的一点是它们是为ui开发而设计的。Facebook在React之后几年开发了RN。

反应: Facebook设计的这个框架几乎就像在HTML/XML中编写JavaScript,这就是为什么标签被称为“JSX”(JavaScript XML),类似于我们熟悉的类似HTML的标签,如<div>或<p>。React的一个标志是大写字母标记,它表示自定义组件,例如<MyFancyNavbar />,它也存在于RN中。然而,React使用DOM。DOM是为HTML而存在的,因此React是用于web开发的。

React Native: RN does not use HTML, and therefore is not used for web development. It is used for... virtually everything else! Mobile development (both iOS & Android), smart-devices (e.g. watches, TVs), augmented reality, etc. As RN has no DOM to interact with, instead of using the same sort of HTML tags used in React, it uses its own tags which are then compiled into other languages. For example, instead of <div> tags, RN developers use RN's built-in <View> tag, which compiles into other native code under the hood (e.g. android.view on Android; and UIView on iOS).

简而言之:它们非常相似(对于UI开发),但用于不同的媒介。

React是一个声明性的、高效的、灵活的JavaScript库,用于构建用户界面。你的组件告诉React你想要呈现什么——然后当你的数据发生变化时,React会有效地更新并呈现正确的组件。这里,ShoppingList是一个React组件类,或者React组件类型。

React Native应用程序是真正的移动应用程序。使用React Native,你不需要构建“移动web应用程序”、“HTML5应用程序”或“混合应用程序”。你构建了一个真正的移动应用,它与使用Objective-C或Java构建的应用没有什么区别。React Native使用与常规iOS和Android应用相同的基本UI构建块。

更多信息

ReactJS是一个javascript库,用于构建web界面。你需要一个像webpack这样的捆绑器,并尝试安装你建立网站所需的模块。

React Native是一个javascript框架,它包含了编写多平台应用程序(如iOS或Android)所需的一切。你需要安装xcode和android studio来构建和部署你的应用。

与ReactJS不同,React-Native不使用HTML,而是使用类似的组件,你可以跨ios和android来构建你的应用程序。这些组件使用真正的本地组件来构建ios和android应用程序。因此,React-Native应用程序感觉真实,不像其他混合开发平台。组件还增加了代码的可重用性,因为你不需要在ios和android上再次创建相同的用户界面。

简单地说,React和React native遵循相同的设计原则,除了在设计用户界面的情况下。

React本机有一组单独的标记来定义user 但是两者都使用JSX来定义组件。 这两个系统的主要目的是开发可重用的ui组件,并通过其组合减少开发工作。 如果你正确地规划和构建代码,你可以在移动和web上使用相同的业务逻辑

无论如何,它是一个为移动和网络构建用户界面的优秀库。