(type, props, children)
| 20923 | } |
| 20924 | |
| 20925 | function createElementWithValidation(type, props, children) { |
| 20926 | var validType = typeof type === 'string' || typeof type === 'function' || |
| 20927 | // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill. |
| 20928 | type === REACT_FRAGMENT_TYPE || type === REACT_ASYNC_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE); |
| 20929 | |
| 20930 | // We warn in this case but don't throw. We expect the element creation to |
| 20931 | // succeed and there will likely be errors in render. |
| 20932 | if (!validType) { |
| 20933 | var info = ''; |
| 20934 | if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { |
| 20935 | info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports."; |
| 20936 | } |
| 20937 | |
| 20938 | var sourceInfo = getSourceInfoErrorAddendum(props); |
| 20939 | if (sourceInfo) { |
| 20940 | info += sourceInfo; |
| 20941 | } else { |
| 20942 | info += getDeclarationErrorAddendum(); |
| 20943 | } |
| 20944 | |
| 20945 | info += getStackAddendum() || ''; |
| 20946 | |
| 20947 | var typeString = void 0; |
| 20948 | if (type === null) { |
| 20949 | typeString = 'null'; |
| 20950 | } else if (Array.isArray(type)) { |
| 20951 | typeString = 'array'; |
| 20952 | } else { |
| 20953 | typeString = typeof type; |
| 20954 | } |
| 20955 | |
| 20956 | warning(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info); |
| 20957 | } |
| 20958 | |
| 20959 | var element = createElement.apply(this, arguments); |
| 20960 | |
| 20961 | // The result can be nullish if a mock or a custom function is used. |
| 20962 | // TODO: Drop this when these are no longer allowed as the type argument. |
| 20963 | if (element == null) { |
| 20964 | return element; |
| 20965 | } |
| 20966 | |
| 20967 | // Skip key warning if the type isn't valid since our key validation logic |
| 20968 | // doesn't expect a non-string/function type and can throw confusing errors. |
| 20969 | // We don't want exception behavior to differ between dev and prod. |
| 20970 | // (Rendering will throw with a helpful message and as soon as the type is |
| 20971 | // fixed, the key warnings will appear.) |
| 20972 | if (validType) { |
| 20973 | for (var i = 2; i < arguments.length; i++) { |
| 20974 | validateChildKeys(arguments[i], type); |
| 20975 | } |
| 20976 | } |
| 20977 | |
| 20978 | if (type === REACT_FRAGMENT_TYPE) { |
| 20979 | validateFragmentProps(element); |
| 20980 | } else { |
| 20981 | validatePropTypes(element); |
| 20982 | } |
nothing calls this directly
no test coverage detected