MCPcopy Create free account
hub / github.com/reactjs/react-rails / ReactElement

Function ReactElement

lib/assets/react-source/development/react.js:1061–1113  ·  view source on GitHub ↗
(type, key, ref, self, source, owner, props)

Source from the content-addressed store, hash-verified

1059
1060
1061 var ReactElement = function (type, key, ref, self, source, owner, props) {
1062 var element = {
1063 // This tag allows us to uniquely identify this as a React Element
1064 $$typeof: REACT_ELEMENT_TYPE,
1065 // Built-in properties that belong on the element
1066 type: type,
1067 key: key,
1068 ref: ref,
1069 props: props,
1070 // Record the component responsible for creating this element.
1071 _owner: owner
1072 };
1073
1074 {
1075 // The validation flag is currently mutative. We put it on
1076 // an external backing store so that we can freeze the whole object.
1077 // This can be replaced with a WeakMap once they are implemented in
1078 // commonly used development environments.
1079 element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
1080 // the validation flag non-enumerable (where possible, which should
1081 // include every environment we run tests in), so the test framework
1082 // ignores it.
1083
1084 Object.defineProperty(element._store, 'validated', {
1085 configurable: false,
1086 enumerable: false,
1087 writable: true,
1088 value: false
1089 }); // self and source are DEV only properties.
1090
1091 Object.defineProperty(element, '_self', {
1092 configurable: false,
1093 enumerable: false,
1094 writable: false,
1095 value: self
1096 }); // Two elements created in two different places should be considered
1097 // equal for testing purposes and therefore we hide it from enumeration.
1098
1099 Object.defineProperty(element, '_source', {
1100 configurable: false,
1101 enumerable: false,
1102 writable: false,
1103 value: source
1104 });
1105
1106 if (Object.freeze) {
1107 Object.freeze(element.props);
1108 Object.freeze(element);
1109 }
1110 }
1111
1112 return element;
1113 };
1114 /**
1115 * Create and return a new ReactElement of the given type.
1116 * See https://reactjs.org/docs/react-api.html#createelement

Callers 3

createElementFunction · 0.70
cloneAndReplaceKeyFunction · 0.70
cloneElementFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected