我已经开始学习React出于好奇,想知道React和React Native之间的区别-虽然不能找到一个满意的答案使用谷歌。React和React Native似乎有相同的格式。它们的语法完全不同吗?
当前回答
一些区别如下: 1- React-Native是一个用于创建移动应用程序的框架,其中ReactJS是一个javascript库,可以用于您的网站。 2- React- native不使用HTML来渲染应用程序,而React使用。 3- React- native只用于开发移动应用程序,而React用于网站和移动。
其他回答
为了回应上面@poshest的评论,这里有一个React Native版本的时钟代码,之前在React中发布(抱歉,我无法直接评论这部分,否则我会在那里添加代码):
React Native代码示例
import { AppRegistry } from 'react-native';
import React, { Component } from 'react';
import { View, Text, StyleSheet } from 'react-native';
class Clock extends Component {
constructor(props) {
super(props);
this.state = { date: new Date() };
}
componentDidMount() {
this.timerID = setInterval(
() => this.tick(),
1000
);
}
componentWillUnmount() {
clearInterval(this.timerID);
}
tick() {
this.setState({
date: new Date()
});
}
render() {
return (
<View style={styles.container}>
<Text style={styles.sectionTitle}>Hello, world!</Text>
<Text style={styles.sectionDescription}>It is {this.state.date.toLocaleTimeString()}.</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
backgroundColor: 'white',
flex: 1,
justifyContent: 'center',
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
color: 'black',
alignSelf: 'center',
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
color: 'darkgrey',
alignSelf: 'center',
},
});
AppRegistry.registerComponent("clock", () => Clock);
注意,样式完全是我的选择,并不寻求直接复制在React代码中使用的<h1>和<h2>标记。
简单的React Js是为web React Native是为跨平台移动应用程序!
React Native是为移动应用程序,而React是为网站(前端)。这两个框架都是Facebook发明的。React Native是一个跨平台的开发框架,这意味着你可以为IOS和Android编写几乎相同的代码,而且它可以工作。我个人对React Native了解更多,所以我就到此为止。
反应
React is used for creating websites, web apps, SPAs etc. React is a Javascript library used for creating UI hierarchy. It is responsible for rendering of UI components, It is considered as V part Of MVC framework. React’s virtual DOM is faster than the conventional full refresh model, since the virtual DOM refreshes only parts of the page, Thus decreasing the page refresh time. React uses components as basic unit of UI which can be reused this saves coding time. Simple and easy to learn. React Native React Native is a framework that is used to create cross-platform Native apps. It means you can create native apps and the same app will run on Android and ios. React native have all the benefits of ReactJS React native allows developers to create native apps in web-style approach.
React Native主要是用JavaScript开发的,这意味着你需要开始的大部分代码都可以跨平台共享。React Native将使用本地组件进行渲染。React Native应用程序是用目标平台所需的语言开发的,iOS的Objective-C或Swift, Android的Java等。所编写的代码不是跨平台共享的,它们的行为各不相同。他们可以直接使用平台提供的所有功能,不受任何限制。
React是Facebook开发的一个开源JavaScript库,用于构建用户界面。它用于处理web和移动应用程序的视图层。ReactJS用于创建可重用的UI组件。它是目前It领域最流行的JavaScript库之一,它有强大的基础和庞大的社区支持。如果你学习ReactJS,你需要有JavaScript, HTML5和CSS的知识。
推荐文章
- 我如何使用Jest模拟JavaScript的“窗口”对象?
- 在应用程序启动时出现“无法获得BatchedBridge,请确保您的bundle被正确打包”的错误
- React组件中使用TypeScript的默认属性值
- 我如何等待一个承诺完成之前返回一个函数的变量?
- 在JavaScript中根据键值查找和删除数组中的对象
- 使嵌套JavaScript对象平放/不平放的最快方法
- 如何以及为什么'a'['toUpperCase']()在JavaScript工作?
- 有Grunt生成index.html不同的设置
- 文档之间的区别。addEventListener和window。addEventListener?
- 如何检查动态附加的事件监听器是否存在?
- 如何写setTimeout与参数Coffeescript
- 将JavaScript字符串中的多个空格替换为单个空格
- JavaScript: override alert()
- 重置setTimeout
- 如何确保<select>表单字段被禁用时提交?