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

Function createElement

code/new-context-api/public/app.js:18158–18228  ·  view source on GitHub ↗

* Create and return a new ReactElement of the given type. * See https://reactjs.org/docs/react-api.html#createelement

(type, config, children)

Source from the content-addressed store, hash-verified

18156 * See https://reactjs.org/docs/react-api.html#createelement
18157 */
18158function createElement(type, config, children) {
18159 var propName = void 0;
18160
18161 // Reserved names are extracted
18162 var props = {};
18163
18164 var key = null;
18165 var ref = null;
18166 var self = null;
18167 var source = null;
18168
18169 if (config != null) {
18170 if (hasValidRef(config)) {
18171 ref = config.ref;
18172 }
18173 if (hasValidKey(config)) {
18174 key = '' + config.key;
18175 }
18176
18177 self = config.__self === undefined ? null : config.__self;
18178 source = config.__source === undefined ? null : config.__source;
18179 // Remaining properties are added to a new props object
18180 for (propName in config) {
18181 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
18182 props[propName] = config[propName];
18183 }
18184 }
18185 }
18186
18187 // Children can be more than one argument, and those are transferred onto
18188 // the newly allocated props object.
18189 var childrenLength = arguments.length - 2;
18190 if (childrenLength === 1) {
18191 props.children = children;
18192 } else if (childrenLength > 1) {
18193 var childArray = Array(childrenLength);
18194 for (var i = 0; i < childrenLength; i++) {
18195 childArray[i] = arguments[i + 2];
18196 }
18197 {
18198 if (Object.freeze) {
18199 Object.freeze(childArray);
18200 }
18201 }
18202 props.children = childArray;
18203 }
18204
18205 // Resolve default props
18206 if (type && type.defaultProps) {
18207 var defaultProps = type.defaultProps;
18208 for (propName in defaultProps) {
18209 if (props[propName] === undefined) {
18210 props[propName] = defaultProps[propName];
18211 }
18212 }
18213 }
18214 {
18215 if (key || ref) {

Callers 1

app.jsFile · 0.70

Calls 5

hasValidRefFunction · 0.70
hasValidKeyFunction · 0.70
ReactElementFunction · 0.70

Tested by

no test coverage detected