MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / ReactElement

Function ReactElement

code/redux/public/app.js:20081–20135  ·  view source on GitHub ↗
(type, key, ref, self, source, owner, props)

Source from the content-addressed store, hash-verified

20079 * @internal
20080 */
20081var ReactElement = function (type, key, ref, self, source, owner, props) {
20082 var element = {
20083 // This tag allows us to uniquely identify this as a React Element
20084 $$typeof: REACT_ELEMENT_TYPE,
20085
20086 // Built-in properties that belong on the element
20087 type: type,
20088 key: key,
20089 ref: ref,
20090 props: props,
20091
20092 // Record the component responsible for creating this element.
20093 _owner: owner
20094 };
20095
20096 {
20097 // The validation flag is currently mutative. We put it on
20098 // an external backing store so that we can freeze the whole object.
20099 // This can be replaced with a WeakMap once they are implemented in
20100 // commonly used development environments.
20101 element._store = {};
20102
20103 // To make comparing ReactElements easier for testing purposes, we make
20104 // the validation flag non-enumerable (where possible, which should
20105 // include every environment we run tests in), so the test framework
20106 // ignores it.
20107 Object.defineProperty(element._store, 'validated', {
20108 configurable: false,
20109 enumerable: false,
20110 writable: true,
20111 value: false
20112 });
20113 // self and source are DEV only properties.
20114 Object.defineProperty(element, '_self', {
20115 configurable: false,
20116 enumerable: false,
20117 writable: false,
20118 value: self
20119 });
20120 // Two elements created in two different places should be considered
20121 // equal for testing purposes and therefore we hide it from enumeration.
20122 Object.defineProperty(element, '_source', {
20123 configurable: false,
20124 enumerable: false,
20125 writable: false,
20126 value: source
20127 });
20128 if (Object.freeze) {
20129 Object.freeze(element.props);
20130 Object.freeze(element);
20131 }
20132 }
20133
20134 return element;
20135};
20136
20137/**
20138 * Create and return a new ReactElement of the given type.

Callers 3

createElementFunction · 0.70
cloneAndReplaceKeyFunction · 0.70
cloneElementFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected