为什么 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'), //
随机推荐
- 对一个 复杂的json结果进行取值的例子
1 JSON结果集 [ { "J_LP_OPERATE_MAIN": { "ID": "1900036295", "FILL_MA ...
- 把CString转化为char*
转:http://blog.sina.com.cn/s/blog_58e19ae7010003jt.html 正确方法:CString m_Head:char *codefile;codefile=( ...
- interrupt和isInterrupted的基本使用方法
java线程是协作式,而非抢占式 调用一个线程的interrupt() 方法中断一个线程,并不是强行关闭这个线程,只是跟这个线程打个招呼,将线程的中断标志位置为true,线程是否中断,由线程本身决定. ...
- redis的连接方法|连接池|操作
1.先看下redis的连接 import redis # 连接服务端 r = redis.Redis(host="127.0.0.1",port=6379) #获取所有的key值 ...
- GlobalMemoryStatusEx获取内存
typedef struct _MEMORYSTATUSEX { DWORD dwLength; DWORD dwMemoryLoad; DWORDLONG ullTotalPhys; DWORDLO ...
- 安装python-empy
sudo python setup.py install
- java 内存 线程 类 vm分析工具
JMeter.Jconsole.JVMStat
- Andriod 之数据获取
服务端Model using System; using System.Collections.Generic; using System.Linq; using System.Web; namesp ...
- 线上服务 CPU 100%?一键定位 so easy!
转自: https://my.oschina.net/leejun2005/blog/1524687 摘要: 本文主要针对 Java 服务而言 0.背景 经常做后端服务开发的同学,或多或少都 ...
- Codeforces758C Unfair Poll 2017-01-20 10:24 95人阅读 评论(0) 收藏
C. Unfair Poll time limit per test 1 second memory limit per test 256 megabytes input standard input ...