MCPcopy Create free account
hub / github.com/plotly/dash / checkPropTypes

Function checkPropTypes

dash/deps/react@18.2.0.js:2024–2071  ·  view source on GitHub ↗
(typeSpecs, values, location, componentName, element)

Source from the content-addressed store, hash-verified

2022 }
2023
2024 function checkPropTypes(typeSpecs, values, location, componentName, element) {
2025 {
2026 // $FlowFixMe This is okay but Flow doesn't know it.
2027 var has = Function.call.bind(hasOwnProperty);
2028
2029 for (var typeSpecName in typeSpecs) {
2030 if (has(typeSpecs, typeSpecName)) {
2031 var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
2032 // fail the render phase where it didn't fail before. So we log it.
2033 // After these have been cleaned up, we'll let them throw.
2034
2035 try {
2036 // This is intentionally an invariant that gets caught. It's the same
2037 // behavior as without this statement except with a better message.
2038 if (typeof typeSpecs[typeSpecName] !== 'function') {
2039 // eslint-disable-next-line react-internal/prod-error-codes
2040 var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
2041 err.name = 'Invariant Violation';
2042 throw err;
2043 }
2044
2045 error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
2046 } catch (ex) {
2047 error$1 = ex;
2048 }
2049
2050 if (error$1 && !(error$1 instanceof Error)) {
2051 setCurrentlyValidatingElement(element);
2052
2053 error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
2054
2055 setCurrentlyValidatingElement(null);
2056 }
2057
2058 if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
2059 // Only monitor this failure once because there tends to be a lot of the
2060 // same error.
2061 loggedTypeFailures[error$1.message] = true;
2062 setCurrentlyValidatingElement(element);
2063
2064 error('Failed %s type: %s', location, error$1.message);
2065
2066 setCurrentlyValidatingElement(null);
2067 }
2068 }
2069 }
2070 }
2071 }
2072
2073 function setCurrentlyValidatingElement$1(element) {
2074 {

Callers 1

validatePropTypesFunction · 0.70

Calls 3

hasFunction · 0.70
errorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…