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

Function ReactElement

code/one-direction-data-flow/public/app.js:18610–18664  ·  view source on GitHub ↗
(type, key, ref, self, source, owner, props)

Source from the content-addressed store, hash-verified

18608 * @internal
18609 */
18610var ReactElement = function (type, key, ref, self, source, owner, props) {
18611 var element = {
18612 // This tag allows us to uniquely identify this as a React Element
18613 $$typeof: REACT_ELEMENT_TYPE,
18614
18615 // Built-in properties that belong on the element
18616 type: type,
18617 key: key,
18618 ref: ref,
18619 props: props,
18620
18621 // Record the component responsible for creating this element.
18622 _owner: owner
18623 };
18624
18625 {
18626 // The validation flag is currently mutative. We put it on
18627 // an external backing store so that we can freeze the whole object.
18628 // This can be replaced with a WeakMap once they are implemented in
18629 // commonly used development environments.
18630 element._store = {};
18631
18632 // To make comparing ReactElements easier for testing purposes, we make
18633 // the validation flag non-enumerable (where possible, which should
18634 // include every environment we run tests in), so the test framework
18635 // ignores it.
18636 Object.defineProperty(element._store, 'validated', {
18637 configurable: false,
18638 enumerable: false,
18639 writable: true,
18640 value: false
18641 });
18642 // self and source are DEV only properties.
18643 Object.defineProperty(element, '_self', {
18644 configurable: false,
18645 enumerable: false,
18646 writable: false,
18647 value: self
18648 });
18649 // Two elements created in two different places should be considered
18650 // equal for testing purposes and therefore we hide it from enumeration.
18651 Object.defineProperty(element, '_source', {
18652 configurable: false,
18653 enumerable: false,
18654 writable: false,
18655 value: source
18656 });
18657 if (Object.freeze) {
18658 Object.freeze(element.props);
18659 Object.freeze(element);
18660 }
18661 }
18662
18663 return element;
18664};
18665
18666/**
18667 * 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