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

Function createElement

code/communication/public/app.js:18832–18902  ·  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

18830 * See https://reactjs.org/docs/react-api.html#createelement
18831 */
18832function createElement(type, config, children) {
18833 var propName = void 0;
18834
18835 // Reserved names are extracted
18836 var props = {};
18837
18838 var key = null;
18839 var ref = null;
18840 var self = null;
18841 var source = null;
18842
18843 if (config != null) {
18844 if (hasValidRef(config)) {
18845 ref = config.ref;
18846 }
18847 if (hasValidKey(config)) {
18848 key = '' + config.key;
18849 }
18850
18851 self = config.__self === undefined ? null : config.__self;
18852 source = config.__source === undefined ? null : config.__source;
18853 // Remaining properties are added to a new props object
18854 for (propName in config) {
18855 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
18856 props[propName] = config[propName];
18857 }
18858 }
18859 }
18860
18861 // Children can be more than one argument, and those are transferred onto
18862 // the newly allocated props object.
18863 var childrenLength = arguments.length - 2;
18864 if (childrenLength === 1) {
18865 props.children = children;
18866 } else if (childrenLength > 1) {
18867 var childArray = Array(childrenLength);
18868 for (var i = 0; i < childrenLength; i++) {
18869 childArray[i] = arguments[i + 2];
18870 }
18871 {
18872 if (Object.freeze) {
18873 Object.freeze(childArray);
18874 }
18875 }
18876 props.children = childArray;
18877 }
18878
18879 // Resolve default props
18880 if (type && type.defaultProps) {
18881 var defaultProps = type.defaultProps;
18882 for (propName in defaultProps) {
18883 if (props[propName] === undefined) {
18884 props[propName] = defaultProps[propName];
18885 }
18886 }
18887 }
18888 {
18889 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