(type, props, children)
| 18909 | } |
| 18910 | |
| 18911 | function createElementWithValidation(type, props, children) { |
| 18912 | var validType = typeof type === 'string' || typeof type === 'function' || |
| 18913 | // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill. |
| 18914 | 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); |
| 18915 | |
| 18916 | // We warn in this case but don't throw. We expect the element creation to |
| 18917 | // succeed and there will likely be errors in render. |
| 18918 | if (!validType) { |
| 18919 | var info = ''; |
| 18920 | if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { |
| 18921 | 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."; |
| 18922 | } |
| 18923 | |
| 18924 | var sourceInfo = getSourceInfoErrorAddendum(props); |
| 18925 | if (sourceInfo) { |
| 18926 | info += sourceInfo; |
| 18927 | } else { |
| 18928 | info += getDeclarationErrorAddendum(); |
| 18929 | } |
| 18930 | |
| 18931 | info += getStackAddendum() || ''; |
| 18932 | |
| 18933 | var typeString = void 0; |
| 18934 | if (type === null) { |
| 18935 | typeString = 'null'; |
| 18936 | } else if (Array.isArray(type)) { |
| 18937 | typeString = 'array'; |
| 18938 | } else { |
| 18939 | typeString = typeof type; |
| 18940 | } |
| 18941 | |
| 18942 | 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); |
| 18943 | } |
| 18944 | |
| 18945 | var element = createElement.apply(this, arguments); |
| 18946 | |
| 18947 | // The result can be nullish if a mock or a custom function is used. |
| 18948 | // TODO: Drop this when these are no longer allowed as the type argument. |
| 18949 | if (element == null) { |
| 18950 | return element; |
| 18951 | } |
| 18952 | |
| 18953 | // Skip key warning if the type isn't valid since our key validation logic |
| 18954 | // doesn't expect a non-string/function type and can throw confusing errors. |
| 18955 | // We don't want exception behavior to differ between dev and prod. |
| 18956 | // (Rendering will throw with a helpful message and as soon as the type is |
| 18957 | // fixed, the key warnings will appear.) |
| 18958 | if (validType) { |
| 18959 | for (var i = 2; i < arguments.length; i++) { |
| 18960 | validateChildKeys(arguments[i], type); |
| 18961 | } |
| 18962 | } |
| 18963 | |
| 18964 | if (type === REACT_FRAGMENT_TYPE) { |
| 18965 | validateFragmentProps(element); |
| 18966 | } else { |
| 18967 | validatePropTypes(element); |
| 18968 | } |
nothing calls this directly
no test coverage detected