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

Function ReactElement

code/new-context-api/public/app.js:18098–18152  ·  view source on GitHub ↗
(type, key, ref, self, source, owner, props)

Source from the content-addressed store, hash-verified

18096 * @internal
18097 */
18098var ReactElement = function (type, key, ref, self, source, owner, props) {
18099 var element = {
18100 // This tag allows us to uniquely identify this as a React Element
18101 $$typeof: REACT_ELEMENT_TYPE,
18102
18103 // Built-in properties that belong on the element
18104 type: type,
18105 key: key,
18106 ref: ref,
18107 props: props,
18108
18109 // Record the component responsible for creating this element.
18110 _owner: owner
18111 };
18112
18113 {
18114 // The validation flag is currently mutative. We put it on
18115 // an external backing store so that we can freeze the whole object.
18116 // This can be replaced with a WeakMap once they are implemented in
18117 // commonly used development environments.
18118 element._store = {};
18119
18120 // To make comparing ReactElements easier for testing purposes, we make
18121 // the validation flag non-enumerable (where possible, which should
18122 // include every environment we run tests in), so the test framework
18123 // ignores it.
18124 Object.defineProperty(element._store, 'validated', {
18125 configurable: false,
18126 enumerable: false,
18127 writable: true,
18128 value: false
18129 });
18130 // self and source are DEV only properties.
18131 Object.defineProperty(element, '_self', {
18132 configurable: false,
18133 enumerable: false,
18134 writable: false,
18135 value: self
18136 });
18137 // Two elements created in two different places should be considered
18138 // equal for testing purposes and therefore we hide it from enumeration.
18139 Object.defineProperty(element, '_source', {
18140 configurable: false,
18141 enumerable: false,
18142 writable: false,
18143 value: source
18144 });
18145 if (Object.freeze) {
18146 Object.freeze(element.props);
18147 Object.freeze(element);
18148 }
18149 }
18150
18151 return element;
18152};
18153
18154/**
18155 * 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