React Core Features
React Core Features
Here is a summary of the core features. We will cover each feature in detail throughout the examples.
JSX (JavaScript Syntax Extension)
- JSX has a concise and familiar syntax for defining tree structures with attributes
- JSX syntax needs to be transpiled to JavaScript (i.e. by Babel)
- In contrast to JavaScript, JSX is statically-typed
- JSX uses ES6 classes, which are similar to Java
One-way data flow
- Properties are passed by the parent component to the child components
- The properties are treated as immutable values
- Child components should never directly modify any properties that are passed to them
- PropTypes can be used for defining the type of each property that is passed to a given component. If a component receives an invalid value for a property, there will be a warning in the console. PropTypes are checked during runtime
Virtual DOM
- React uses the Virtual DOM to create an in-memory copy of the browsers DOM
- When changing the state of components, React updates the virtual DOM first
- After that it computes the resulting differences, and updates the browser’s displayed DOM efficiently
Lifecycle methods
These methods can be overridden for each component, to run code during a specific lifecycle phase.
- Mounting:
constructor()
componentWillMount()
render()
componentDidMount()
- Updating:
componentWillReceiveProps()
shouldComponentUpdate()
componentWillUpdate()
render()
componentDidUpdate()
- Unmounting:
componentWillUnmount()
- Error handling (since React 16 – released September 2017):
componentDidCatch()
We will explain these core features in more detail with a couple of code snippets in the next section.
Babel (ES5, ES6)
The JavaScript syntax that you will see in our examples is ECMAScript 6 (ES6) notation. If you need to run your web app inside older web browsers, you can use Babel (https://babeljs.io/) to transpile ES6 code to ES5. Here is an example how babel will transpile the ES6 arrow function to a regular ES5 function.
ES6 syntax | Transpiled to ES5 syntax |
[1,2,3,4].map(n => n + 1); |
[1,2,3,4].map( |
https://blog.codecentric.de/en/2017/11/developing-modern-offline-apps-reactjs-redux-electron-part-2-reactjs-basics/
React Core Features的更多相关文章
- 解决CocoaPods could not find compatible versions for pod "React/Core"
react-native框架中,在ios文件夹下执行pod install命令时出现的问题. 下面时完整的异常信息: [!] CocoaPods could not find compatible v ...
- react new features 2020
react new features 2020 https://insights.stackoverflow.com/survey/2019#technology-_-web-frameworks h ...
- React Native pod install报错 `Yoga (= 0.44.3.React)` required by `React/Core (0.44.3)`
使用pod安装,可能会因为Podfile的路径指向错误或者没有路径指向因为报错. 报错截图如下: 这是因为在指定的路径没有寻找到相应的组件.此时就需要修改podfile文件中的路径,由于上方提示没有 ...
- SpringBoot(四) Core Features: Logging
参考 文档: 26. Logging
- SpringBoot(二) Core Features: SpringApplication
参考 文档: SpringApplication
- SpringBoot(三) Core Features: External Configuration(配置文件)
码云: external-configuration 可以使用属性文件,YAML文件,环境变量和命令行参数来外部化配置 一.属性值可以直接注入到bean 系统属性值不可以 // application ...
- react programming
So you're curious in learning this new thing called Reactive Programming, particularly its variant c ...
- .NET Core 和 .NET Framework 之间的关系
引用一段描述:Understanding the relationship between .NET Core and the .NET Framework. .NET Core and the .N ...
- Professional C# 6 and .NET Core 1.0 - 40 ASP.NET Core
本文内容为转载,重新排版以供学习研究.如有侵权,请联系作者删除. 转载请注明本文出处:Professional C# 6 and .NET Core 1.0 - 40 ASP.NET Core --- ...
随机推荐
- angular get 数据请求
数据请求 get 新建一个服务 1. ng g service services /+服务名 eg:ng g service services/player 在此服务中进行设置 引入自带组件以及注册 ...
- 解决www.coursera.org可以登录但无法播放视频
- 超简单的VUE在线调试网站(不需搭建环境)
jsbin.com提供简单.直观.易用的vue调试功能,最大的好处不需要自己搭建环境就可以学习VUE 1.打开http://jsbin.com/joxinumota/edit?html,js,cons ...
- 【开发笔记】-通过js控制input禁止输入空格
<input type="text" id="fname" onkeyup="myFunction(id)"> <scri ...
- HTML5深入学习之鼠标跟随,拖拽事件
知识点(鼠标跟随): mousedown: 当用户用鼠标点击在某一元素上就会触发该事件 mouseover: 当鼠标指针在某一元素上移动就会触发改事件 下面这个例子的效果就是鼠标点击元素后,元素跟着 ...
- phpStudy配置多站点多域名和多端口的方法
切记:要想多个域名指向同一个项目,必须将phpstudy的根目录指向你项目所指的地方(原根目录是WWW),修改位置(其他菜单选项 - 软件设置 - 端口常规设置 - 网站目录) 站点:类似于 WWW ...
- Springboot2 jpa druid多数据源
package com.ruoyi; import org.mybatis.spring.annotation.MapperScan; import org.springframework.beans ...
- centos逻辑卷使用
要求: 1.硬盘格式成物理卷pvpvcreate/dev/sdb/dev/sda 2.创建卷组vgcreatevg1000/dev/sdb1/dev/sdb2#创建卷组”vg1000” 3.增加卷组 ...
- BERT解析及文本分类应用
目录 前言 BERT模型概览 Seq2Seq Attention Transformer encoder部分 Decoder部分 BERT Embedding 预训练 文本分类试验 参考文献 前言 在 ...
- JAVA项目从运维部署到项目开发(四. Tomcat)
一.关于中文乱码问题 文件目录:/conf/server.xml 将相关语句改为: <Connector port="8008" protocol="HTTP/1. ...