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

Function ReactElement

code/higher-order-components/public/app.js:18731–18785  ·  view source on GitHub ↗
(type, key, ref, self, source, owner, props)

Source from the content-addressed store, hash-verified

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