MCPcopy Index your code
hub / github.com/plotly/dash / createElementWithValidation

Function createElementWithValidation

dash/deps/react@16.14.0.js:1946–2008  ·  view source on GitHub ↗
(type, props, children)

Source from the content-addressed store, hash-verified

1944 }
1945 }
1946 function createElementWithValidation(type, props, children) {
1947 var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
1948 // succeed and there will likely be errors in render.
1949
1950 if (!validType) {
1951 var info = '';
1952
1953 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
1954 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.";
1955 }
1956
1957 var sourceInfo = getSourceInfoErrorAddendumForProps(props);
1958
1959 if (sourceInfo) {
1960 info += sourceInfo;
1961 } else {
1962 info += getDeclarationErrorAddendum();
1963 }
1964
1965 var typeString;
1966
1967 if (type === null) {
1968 typeString = 'null';
1969 } else if (Array.isArray(type)) {
1970 typeString = 'array';
1971 } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
1972 typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
1973 info = ' Did you accidentally export a JSX literal instead of a component?';
1974 } else {
1975 typeString = typeof type;
1976 }
1977
1978 {
1979 error('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);
1980 }
1981 }
1982
1983 var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used.
1984 // TODO: Drop this when these are no longer allowed as the type argument.
1985
1986 if (element == null) {
1987 return element;
1988 } // Skip key warning if the type isn't valid since our key validation logic
1989 // doesn't expect a non-string/function type and can throw confusing errors.
1990 // We don't want exception behavior to differ between dev and prod.
1991 // (Rendering will throw with a helpful message and as soon as the type is
1992 // fixed, the key warnings will appear.)
1993
1994
1995 if (validType) {
1996 for (var i = 2; i < arguments.length; i++) {
1997 validateChildKeys(arguments[i], type);
1998 }
1999 }
2000
2001 if (type === REACT_FRAGMENT_TYPE) {
2002 validateFragmentProps(element);
2003 } else {

Callers

nothing calls this directly

Calls 10

keysMethod · 0.80
isValidElementTypeFunction · 0.70
getComponentNameFunction · 0.70
errorFunction · 0.70
validateChildKeysFunction · 0.70
validateFragmentPropsFunction · 0.70
validatePropTypesFunction · 0.70
applyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…