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

Function ReactElement

code/third-party/public/app.js:17970–18024  ·  view source on GitHub ↗
(type, key, ref, self, source, owner, props)

Source from the content-addressed store, hash-verified

17968 * @internal
17969 */
17970var ReactElement = function (type, key, ref, self, source, owner, props) {
17971 var element = {
17972 // This tag allows us to uniquely identify this as a React Element
17973 $$typeof: REACT_ELEMENT_TYPE,
17974
17975 // Built-in properties that belong on the element
17976 type: type,
17977 key: key,
17978 ref: ref,
17979 props: props,
17980
17981 // Record the component responsible for creating this element.
17982 _owner: owner
17983 };
17984
17985 {
17986 // The validation flag is currently mutative. We put it on
17987 // an external backing store so that we can freeze the whole object.
17988 // This can be replaced with a WeakMap once they are implemented in
17989 // commonly used development environments.
17990 element._store = {};
17991
17992 // To make comparing ReactElements easier for testing purposes, we make
17993 // the validation flag non-enumerable (where possible, which should
17994 // include every environment we run tests in), so the test framework
17995 // ignores it.
17996 Object.defineProperty(element._store, 'validated', {
17997 configurable: false,
17998 enumerable: false,
17999 writable: true,
18000 value: false
18001 });
18002 // self and source are DEV only properties.
18003 Object.defineProperty(element, '_self', {
18004 configurable: false,
18005 enumerable: false,
18006 writable: false,
18007 value: self
18008 });
18009 // Two elements created in two different places should be considered
18010 // equal for testing purposes and therefore we hide it from enumeration.
18011 Object.defineProperty(element, '_source', {
18012 configurable: false,
18013 enumerable: false,
18014 writable: false,
18015 value: source
18016 });
18017 if (Object.freeze) {
18018 Object.freeze(element.props);
18019 Object.freeze(element);
18020 }
18021 }
18022
18023 return element;
18024};
18025
18026/**
18027 * 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