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

Function createElement

code/redux/public/app.js:20141–20211  ·  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

20139 * See https://reactjs.org/docs/react-api.html#createelement
20140 */
20141function createElement(type, config, children) {
20142 var propName = void 0;
20143
20144 // Reserved names are extracted
20145 var props = {};
20146
20147 var key = null;
20148 var ref = null;
20149 var self = null;
20150 var source = null;
20151
20152 if (config != null) {
20153 if (hasValidRef(config)) {
20154 ref = config.ref;
20155 }
20156 if (hasValidKey(config)) {
20157 key = '' + config.key;
20158 }
20159
20160 self = config.__self === undefined ? null : config.__self;
20161 source = config.__source === undefined ? null : config.__source;
20162 // Remaining properties are added to a new props object
20163 for (propName in config) {
20164 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
20165 props[propName] = config[propName];
20166 }
20167 }
20168 }
20169
20170 // Children can be more than one argument, and those are transferred onto
20171 // the newly allocated props object.
20172 var childrenLength = arguments.length - 2;
20173 if (childrenLength === 1) {
20174 props.children = children;
20175 } else if (childrenLength > 1) {
20176 var childArray = Array(childrenLength);
20177 for (var i = 0; i < childrenLength; i++) {
20178 childArray[i] = arguments[i + 2];
20179 }
20180 {
20181 if (Object.freeze) {
20182 Object.freeze(childArray);
20183 }
20184 }
20185 props.children = childArray;
20186 }
20187
20188 // Resolve default props
20189 if (type && type.defaultProps) {
20190 var defaultProps = type.defaultProps;
20191 for (propName in defaultProps) {
20192 if (props[propName] === undefined) {
20193 props[propName] = defaultProps[propName];
20194 }
20195 }
20196 }
20197 {
20198 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