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

Function ReactElement

code/styling/public/app.js:18737–18791  ·  view source on GitHub ↗
(type, key, ref, self, source, owner, props)

Source from the content-addressed store, hash-verified

18735 * @internal
18736 */
18737var ReactElement = function (type, key, ref, self, source, owner, props) {
18738 var element = {
18739 // This tag allows us to uniquely identify this as a React Element
18740 $$typeof: REACT_ELEMENT_TYPE,
18741
18742 // Built-in properties that belong on the element
18743 type: type,
18744 key: key,
18745 ref: ref,
18746 props: props,
18747
18748 // Record the component responsible for creating this element.
18749 _owner: owner
18750 };
18751
18752 {
18753 // The validation flag is currently mutative. We put it on
18754 // an external backing store so that we can freeze the whole object.
18755 // This can be replaced with a WeakMap once they are implemented in
18756 // commonly used development environments.
18757 element._store = {};
18758
18759 // To make comparing ReactElements easier for testing purposes, we make
18760 // the validation flag non-enumerable (where possible, which should
18761 // include every environment we run tests in), so the test framework
18762 // ignores it.
18763 Object.defineProperty(element._store, 'validated', {
18764 configurable: false,
18765 enumerable: false,
18766 writable: true,
18767 value: false
18768 });
18769 // self and source are DEV only properties.
18770 Object.defineProperty(element, '_self', {
18771 configurable: false,
18772 enumerable: false,
18773 writable: false,
18774 value: self
18775 });
18776 // Two elements created in two different places should be considered
18777 // equal for testing purposes and therefore we hide it from enumeration.
18778 Object.defineProperty(element, '_source', {
18779 configurable: false,
18780 enumerable: false,
18781 writable: false,
18782 value: source
18783 });
18784 if (Object.freeze) {
18785 Object.freeze(element.props);
18786 Object.freeze(element);
18787 }
18788 }
18789
18790 return element;
18791};
18792
18793/**
18794 * 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