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 --- ...
随机推荐
- php redis扩展安装步骤
因为redis不是php技术自带的技术,因此我们如果要通过php程序来操作redis,需要redis设计者提供对应的操作接口(函数类)我们使用phpredis.tar.gz文件在源码编译生成一个red ...
- drf面试题及总结
drf面试题及总结 1.什么是前后端分离 2.什么是restful规范 3.模拟浏览器进行发送请求的工具 4.查找模板的顺序 5.什么是drf组件 6.drf组件提供的功能 7.drf继承过哪些视图类 ...
- Windows server 2012 显示“我的电脑”
Windows server 2012 桌面上默认没有显示“我的电脑”的快捷方式, 如果要显示,可以输入一行命令: rundll32.exe shell32.dll,Control_RunDLL de ...
- Elasticsearch常见用法-分布式集群
集群内部工作方式 Elasticsearch用于构建高可用和可扩展的系统.扩展的方式可以是购买更好的服务器(纵向扩展(vertical scale or scaling up))或者购买更多的服务器( ...
- easyui-datagrid 加载数据 的两种方法
var start_date_entered=$('#start_date_entered').val(); //创建时间 var stop_date_entered=$('#stop_date_en ...
- .NET / C# EF中的基础操作(CRUD)
查 public List<users> Querys() { datatestEntities db = new datatestEntities(); var a = db.users ...
- rsyslog详解实战和避坑
目标是要把线上环境的debug日志及集中化收集起来,一方面是方便开发调试:一方面是避免直接到线上环境查看,存在安全隐患. 常用可选方案: rsyslog发送端 + rsyslog接收端: 直接存在接收 ...
- ProviderManager
类ProviderManager java.lang.Object继承 org.jivesoftware.smack.provider.ProviderManager public final cla ...
- java log4j 打日志到控制台同时打印到不同文件
1.pom配置 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="htt ...
- 2019 百合佳缘java面试笔试题 (含面试题解析)
本人5年开发经验.18年年底开始跑路找工作,在互联网寒冬下成功拿到阿里巴巴.今日头条.百合佳缘等公司offer,岗位是Java后端开发,因为发展原因最终选择去了百合佳缘,入职一年时间了,也成为了面 ...