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

Function ReactElement

code/communication/public/app.js:18772–18826  ·  view source on GitHub ↗
(type, key, ref, self, source, owner, props)

Source from the content-addressed store, hash-verified

18770 * @internal
18771 */
18772var ReactElement = function (type, key, ref, self, source, owner, props) {
18773 var element = {
18774 // This tag allows us to uniquely identify this as a React Element
18775 $$typeof: REACT_ELEMENT_TYPE,
18776
18777 // Built-in properties that belong on the element
18778 type: type,
18779 key: key,
18780 ref: ref,
18781 props: props,
18782
18783 // Record the component responsible for creating this element.
18784 _owner: owner
18785 };
18786
18787 {
18788 // The validation flag is currently mutative. We put it on
18789 // an external backing store so that we can freeze the whole object.
18790 // This can be replaced with a WeakMap once they are implemented in
18791 // commonly used development environments.
18792 element._store = {};
18793
18794 // To make comparing ReactElements easier for testing purposes, we make
18795 // the validation flag non-enumerable (where possible, which should
18796 // include every environment we run tests in), so the test framework
18797 // ignores it.
18798 Object.defineProperty(element._store, 'validated', {
18799 configurable: false,
18800 enumerable: false,
18801 writable: true,
18802 value: false
18803 });
18804 // self and source are DEV only properties.
18805 Object.defineProperty(element, '_self', {
18806 configurable: false,
18807 enumerable: false,
18808 writable: false,
18809 value: self
18810 });
18811 // Two elements created in two different places should be considered
18812 // equal for testing purposes and therefore we hide it from enumeration.
18813 Object.defineProperty(element, '_source', {
18814 configurable: false,
18815 enumerable: false,
18816 writable: false,
18817 value: source
18818 });
18819 if (Object.freeze) {
18820 Object.freeze(element.props);
18821 Object.freeze(element);
18822 }
18823 }
18824
18825 return element;
18826};
18827
18828/**
18829 * 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