// The Symbol used to tag the ReactElement type. If there is no native Symbol
// nor polyfill, then a plain number is used for performance.
var REACT_ELEMENT_TYPE =
(typeof Symbol === 'function' &&Symbol.for &&Symbol.for('react.element')) ||
0xeac7
var ReactElement = function(type, key, ref, self, source, owner, props) {
var element = {
// This tag allow us to uniquely identify this as a React Element
$$typeof: REACT_ELEMENT_TYPE,
// Built-in properties that belong on the element
type: type,
key: key,
ref: ref,
props: props,
// Record the component responsible for creating this element.
_owner: owner,
}
.....
}
补充一下,它存在的作用。
没有加这个$$typeof之前,object被认为是有效的React Element。为了将React Element和普通的对象区分开,
判断React的children是否是一个React Element, 来尽可能防止xss漏洞。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)