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)

  1. JSX has a concise and familiar syntax for defining tree structures with attributes
  2. JSX syntax needs to be transpiled to JavaScript (i.e. by Babel)
  3. In contrast to JavaScript, JSX is statically-typed
  4. JSX uses ES6 classes, which are similar to Java

One-way data flow

  1. Properties are passed by the parent component to the child components
  2. The properties are treated as immutable values
  3. Child components should never directly modify any properties that are passed to them
  4. 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

  1. React uses the Virtual DOM to create an in-memory copy of the browsers DOM
  2. When changing the state of components, React updates the virtual DOM first
  3. 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.

  1. Mounting:

    • constructor()
    • componentWillMount()
    • render()
    • componentDidMount()
  2. Updating:
    • componentWillReceiveProps()
    • shouldComponentUpdate()
    • componentWillUpdate()
    • render()
    • componentDidUpdate()
  3. Unmounting:
    • componentWillUnmount()
  4. 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(
function(n) {
return n + 1;
}
);

https://blog.codecentric.de/en/2017/11/developing-modern-offline-apps-reactjs-redux-electron-part-2-reactjs-basics/

React Core Features的更多相关文章

  1. 解决CocoaPods could not find compatible versions for pod "React/Core"

    react-native框架中,在ios文件夹下执行pod install命令时出现的问题. 下面时完整的异常信息: [!] CocoaPods could not find compatible v ...

  2. react new features 2020

    react new features 2020 https://insights.stackoverflow.com/survey/2019#technology-_-web-frameworks h ...

  3. React Native pod install报错 `Yoga (= 0.44.3.React)` required by `React/Core (0.44.3)`

    使用pod安装,可能会因为Podfile的路径指向错误或者没有路径指向因为报错. 报错截图如下: 这是因为在指定的路径没有寻找到相应的组件.此时就需要修改podfile文件中的路径,由于上方提示没有  ...

  4. SpringBoot(四) Core Features: Logging

    参考 文档: 26. Logging

  5. SpringBoot(二) Core Features: SpringApplication

    参考 文档: SpringApplication

  6. SpringBoot(三) Core Features: External Configuration(配置文件)

    码云: external-configuration 可以使用属性文件,YAML文件,环境变量和命令行参数来外部化配置 一.属性值可以直接注入到bean 系统属性值不可以 // application ...

  7. react programming

    So you're curious in learning this new thing called Reactive Programming, particularly its variant c ...

  8. .NET Core 和 .NET Framework 之间的关系

    引用一段描述:Understanding the relationship between .NET Core and the .NET Framework. .NET Core and the .N ...

  9. Professional C# 6 and .NET Core 1.0 - 40 ASP.NET Core

    本文内容为转载,重新排版以供学习研究.如有侵权,请联系作者删除. 转载请注明本文出处:Professional C# 6 and .NET Core 1.0 - 40 ASP.NET Core --- ...

随机推荐

  1. SpringCloud 基础

    目录 SpringCloud 基础 一.概述 二.服务发现组件 Eureka 1. 介绍 2. 搭建 Maven 父工程 3. 创建 Eureka 集群 4. 创建服务提供方集群 5. 创建服务消费方 ...

  2. Dart面向对象编程(一)

    基本内容概述: 类与对象: 计算属性: void main(){ var rect = new Rectangle(); rect.width = 20; rect.height = 10; prin ...

  3. Visual Studio pro key license 2019

    仅供学习交流使用,勿用作其他用途!!!!   Visual Studio 2019 Enterprise BF8Y8-GN2QH-T84XB-QVY3B-RC4DF Visual Studio 201 ...

  4. - 集合 遍历 foreach Iterator 并发修改 ConcurrentModificationException MD

    目录 目录 为什么不能在 foreach 循环里进行元素的 remove/add 操作 背景 foreach 循环 问题重现 fail-fast remove/add 做了什么 正确姿势 直接使用普通 ...

  5. 使用PS打开图片的常见姿势

    我们经常会使用PS对现有的图片进行编辑.所以每个人都会经历打开图片这一步骤. 下面为大家介绍一下PS打开图片的这一步的常见方式吧: 第一种:使用文件资源管理器(也就是双击我的电脑弹出来的窗口) 第二种 ...

  6. c# 读取文件目录下的信息

    private void button1_Click(object sender, System.EventArgs e) { //浏览文件夹 this.folderBrowserDialog1.Sh ...

  7. Linux图形界面从登录列表中隐藏用户和开机自动登录

    从GDM-GNOME显示管理器:“ GNOME显示管理器(GDM)是一个管理图形显示服务器并处理图形用户登录的程序.” 显示管理器为X Window System和Wayland用户提供图形登录提示. ...

  8. mvc_第一遍_业务逻辑层和模型

    常用的动态网页对象: 之前我们提到了,使用request对象可以获得和用户请求相关的一系列信息.这一节,我们来看看另外两个常用对象的常规用途. response对象:用于向客户回应.最常用的用法类似于 ...

  9. YAML语言简明教程

    编程免不了要写配置文件,如果你还在用xml/ini/json,就有点过时了,怎么写配置也是一门学问. YAML 是专门用来写配置文件的语言,非常简洁和强大,远比 JSON 格式方便. 本文介绍 YAM ...

  10. VsCode中编写python环境配置

    1. VsCode中编写python环境配置 1.1. 前言 有过开发经验都知道idea一系列的软件虽然功能比较多,但比较容易卡,电脑不好还真容易上火,这里我想要入门python,还是选了款vscod ...