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

Function ReactElement

code/controlled-uncontrolled/public/app.js:18061–18115  ·  view source on GitHub ↗
(type, key, ref, self, source, owner, props)

Source from the content-addressed store, hash-verified

18059 * @internal
18060 */
18061var ReactElement = function (type, key, ref, self, source, owner, props) {
18062 var element = {
18063 // This tag allows us to uniquely identify this as a React Element
18064 $$typeof: REACT_ELEMENT_TYPE,
18065
18066 // Built-in properties that belong on the element
18067 type: type,
18068 key: key,
18069 ref: ref,
18070 props: props,
18071
18072 // Record the component responsible for creating this element.
18073 _owner: owner
18074 };
18075
18076 {
18077 // The validation flag is currently mutative. We put it on
18078 // an external backing store so that we can freeze the whole object.
18079 // This can be replaced with a WeakMap once they are implemented in
18080 // commonly used development environments.
18081 element._store = {};
18082
18083 // To make comparing ReactElements easier for testing purposes, we make
18084 // the validation flag non-enumerable (where possible, which should
18085 // include every environment we run tests in), so the test framework
18086 // ignores it.
18087 Object.defineProperty(element._store, 'validated', {
18088 configurable: false,
18089 enumerable: false,
18090 writable: true,
18091 value: false
18092 });
18093 // self and source are DEV only properties.
18094 Object.defineProperty(element, '_self', {
18095 configurable: false,
18096 enumerable: false,
18097 writable: false,
18098 value: self
18099 });
18100 // Two elements created in two different places should be considered
18101 // equal for testing purposes and therefore we hide it from enumeration.
18102 Object.defineProperty(element, '_source', {
18103 configurable: false,
18104 enumerable: false,
18105 writable: false,
18106 value: source
18107 });
18108 if (Object.freeze) {
18109 Object.freeze(element.props);
18110 Object.freeze(element);
18111 }
18112 }
18113
18114 return element;
18115};
18116
18117/**
18118 * 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