为什么 React Elements 会有 $$typeof 这个属性?
简评:debug 的时候看到 element 对象中有 $$typeof 这属性,于是查了一下这到底干嘛的。
我们知道,通过 JSX 创建一个 React Elements 时:
<marquee bgcolor="#ffa7c4">hi</marquee>
实际上调用的是 React.createElement 方法:
React.createElement(
/* type */ 'marquee',
/* props */ { bgcolor: '#ffa7c4' },
/* children */ 'hi'
)
该方法会返回一个 React Element 对象,大概长这样:
{
type: 'marquee',
props: {
bgcolor: '#ffa7c4',
children: 'hi',
},
key: null,
ref: null,
$$typeof: Symbol.for('react.element'), //
随机推荐
- Python_03-数据类型
1.1 数据类型 基本数据类型:字符串,整数,浮点数,布尔型 集合类型:列表(list), 元组(tuple), 字典(dictionary或hash) 列表(list)的定义: aList = ...
- 12. Integer to Roman (HashTable)
Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...
- C# 将Word,Execl,PPT,Project, 文件转成PDF, 不依赖Office!!
git 地址 https://gitee.com/bandung/Execl_WordTOPDF.git 包括了各种破解的dll Word转PDF 挨个引用 Word转PDF public void ...
- win10系统的快捷键
1.win10特有的快捷键:任务视图和虚拟桌面相关 (1)Win + Tab:查看任务视图 (2)Win + Ctrl + D:在任务视图中新建虚拟桌面 (3)Win + Ctrl + F4:关闭当前 ...
- ibatis 常用标签
prepend:自动在前面加上:自动新手:自动预:自动前置 property:属性 compareValue:指定的常数,值 //判断不相等: <isNotEqual prepend=" ...
- 第七章 资源在Windows编程中的应用 P157 7-8
资源在基于SDK的程序设计中的应用实验 一.实验目的 1.掌握各种资源的应用及资源应用的程序设计方法. 二.实验内容及步骤 实验任务 1.熟悉菜单资源的创建过程: 2.熟悉位图资源的创建: 3.熟 ...
- [Training Video - 2] [Java Introduction] [Install Java and Eclipse, Create Class]
Download Java : https://java.com/en/download/ Download Eclipse : https://www.eclipse.org/downloads/ ...
- Java 设计模式系列(十五)观察者模式(Observer)
Java 设计模式系列(十五)观察者模式(Observer) Java 设计模式系列目录(https://www.cnblogs.com/binarylei/p/10198698.html) Java ...
- Java Thread系列(七)死锁
Java Thread系列(七)死锁 当线程需要同时持有多个锁时,有可能产生死锁.考虑如下情形: 线程 A 当前持有互斥所锁 lock1,线程 B 当前持有互斥锁 lock2.接下来,当线程 A 仍然 ...
- mysql导出导入sql文件方法(linux)
一.导入导出.sql文件for Linux: 1.从mysql中导出数据库test: 在终端运行:mysqldump -h localhost -u root -p test > /home/c ...