PropTypes.element和PropTypes.node的区别
PropTypes.element:指React Element,即React.CreateElement生成的元素,React.CreateElement可以用jsx语法糖表示:
<MyButton color="blue" shadowSize={2}>
Click Me
</MyButton>
编译后为:
React.createElement(
MyButton,
{color: 'blue', shadowSize: 2},
'Click Me'
)
因此PropTypes.element可以为以下类型:string | 组件实列(组件标签,例如上面的<MyButtom>)
PropTypes.node:指React Node,任何可被渲染的元素,包括ReactChild | ReactFragment | ReactPortal | 字符串 | 数字 | 布尔值 | null | undefined | 数组;
摘自大神的回答:
Quote @ferdaber: A more technical explanation is that a valid React node is not the same thing as what is returned by React.createElement. Regardless of what a component ends up rendering, React.createElement always returns an object, which is the JSX.Element interface, but React.ReactNode is the set of all possible return values of a component.
- JSX.Element -> Return value of React.createElement
- React.ReactNode -> Return value of a component
PropTypes.element和PropTypes.node的区别的更多相关文章
- 元素(Element)和结点(Node)的区别(org.w3c.dom)
1.元素(Element)和结点(Node)的区别, 元素是一个小范围的定义,必须是含有完整信息的结点才是一个元素,例如 - . 但是一个结点不一定是一个元素,而一个元素一定是一个结点. 什么是nod ...
- JavaScript中Element与Node的区别,children与childNodes的区别
关于Element跟Node的区别,cilldren跟childNodes的区别很多朋友弄不清楚,本文试图让大家明白这几个概念之间的区别. Node(节点)是DOM层次结构中的任何类型的对象的通用名称 ...
- HTML Element 与 Node 的区别
Element 与 Node 的区别 <html> <head><title>Element & Node</title></head&g ...
- SelectedNode与e.node的区别
SelectedNode与e.node的区别 待补.......
- java Queue中 add/offer,element/peek,remove/poll区别
转自https://blog.csdn.net/u012050154/article/details/60572567 java Queue中 add/offer,element/peek,remov ...
- Element.querySelector和Element.querySelectorAll和jQuery(element).find(selector)选择器的区别
<divid="test1"> <a href="http://www.hujuntao.com/">设计蜂巢</a> &l ...
- js dom node.children与node.childNodes区别
不同点:node.children不会取到节点下面的TextNode但是node.childNodes会取到 共同点:两者都是集合类数组,可以通过索引的方式取到值也可以用for循环遍历
- xml中Node和Element的区别
本文转载自:http://blog.csdn.net/wcydiyi/article/details/4432636点击打开链接 1.元素(Element)和结点(Node)的区别: ...
- 读取XML文件(XmlNode和XmlElement区别)
XmlNode和XmlElement区别.这两个类的功能极其类似(因为我们一般都是在对Element节点进行操作). 1.通过继承关系XmlElement继承自XmlLinkedNode又继承自Xml ...
随机推荐
- [转]初识NuGet - 概念, 安装和使用
1. NuGet是什么? NuGet is a Visual Studio 2010 extension that makes it easy to add, remove, and update l ...
- java性能优化之HashMap,LinkedHashMap,TreeMap读取大量数据效率的比较
很多时候,我们用jdbctemplate或mybatis的时候,为了查询通用,会选择使用map数据结构,因为hashmap本身无序,所以为了保证key的有序性,会采用linkedhashmap.所以我 ...
- ubuntu16 修改gitlab root密码
搭建了一个gitlab的git服务器,默认的管理员为root; 长时间不用root忘记了root密码: 我们可以在服务器上直接重置root的密码: 以下操作在终端下执行 #进入gitlab控制台 su ...
- HandlerMethodReturnValueHandler SpringMVC 参数解析 继承关系以及各解析器解析类型
I HandlerMethodReturnValueHandler (org.springframework.web.method.support) AbstractMessageConverterM ...
- centos6.10环境下启动多个redis实例
# 启动redis端口6379的配置 [root@newcms:/usr/local/nginx/conf]# /etc/redis.conf daemonize yes pidfile /usr/l ...
- Linux终端复制粘贴后前后会多出0~和~1
在终端中执行即可 printf "\e[?2004l" 在终端无法复制问题 set mouse=r
- iOS App转让、转移、迁移(App transfer) -- 仅需四步
当需要将某个 App 出售给其他开发人员,或想要将其移至其他 App Store Connect 组织,则您需要转让该 App.您无需将 App 从 App Store 下架,即可将其所有权转让给另一 ...
- BladeX 部署centos启动顺序
一:启动dockerservice docker start二:启动mysqldocker start mysql三:启动Harborsystemctl restart docker(如有修改daem ...
- 对于之前已经push的项目增加.gitignore配置文件不起作用的处理
.gitignore只能忽略那些原来没有被track的文件,如果某些文件已经被纳入了版本管理中,则修改.gitignore是无效的. 解决方法就是先把本地缓存删除(改变成未track状态),然后再提交 ...
- 使用Docker快速搭建Zookeeper和kafka集群
使用Docker快速搭建Zookeeper和kafka集群 镜像选择 Zookeeper和Kafka集群分别运行在不同的容器中zookeeper官方镜像,版本3.4kafka采用wurstmeiste ...