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

Function ReactElement

code/composition/public/app.js:18875–18929  ·  view source on GitHub ↗
(type, key, ref, self, source, owner, props)

Source from the content-addressed store, hash-verified

18873 * @internal
18874 */
18875var ReactElement = function (type, key, ref, self, source, owner, props) {
18876 var element = {
18877 // This tag allows us to uniquely identify this as a React Element
18878 $$typeof: REACT_ELEMENT_TYPE,
18879
18880 // Built-in properties that belong on the element
18881 type: type,
18882 key: key,
18883 ref: ref,
18884 props: props,
18885
18886 // Record the component responsible for creating this element.
18887 _owner: owner
18888 };
18889
18890 {
18891 // The validation flag is currently mutative. We put it on
18892 // an external backing store so that we can freeze the whole object.
18893 // This can be replaced with a WeakMap once they are implemented in
18894 // commonly used development environments.
18895 element._store = {};
18896
18897 // To make comparing ReactElements easier for testing purposes, we make
18898 // the validation flag non-enumerable (where possible, which should
18899 // include every environment we run tests in), so the test framework
18900 // ignores it.
18901 Object.defineProperty(element._store, 'validated', {
18902 configurable: false,
18903 enumerable: false,
18904 writable: true,
18905 value: false
18906 });
18907 // self and source are DEV only properties.
18908 Object.defineProperty(element, '_self', {
18909 configurable: false,
18910 enumerable: false,
18911 writable: false,
18912 value: self
18913 });
18914 // Two elements created in two different places should be considered
18915 // equal for testing purposes and therefore we hide it from enumeration.
18916 Object.defineProperty(element, '_source', {
18917 configurable: false,
18918 enumerable: false,
18919 writable: false,
18920 value: source
18921 });
18922 if (Object.freeze) {
18923 Object.freeze(element.props);
18924 Object.freeze(element);
18925 }
18926 }
18927
18928 return element;
18929};
18930
18931/**
18932 * 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