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

Function validatePropTypes

dash/deps/react@18.2.0.js:2242–2278  ·  view source on GitHub ↗

* Given an element, validate that its props follow the propTypes definition, * provided by the type. * * @param {ReactElement} element

(element)

Source from the content-addressed store, hash-verified

2240
2241
2242 function validatePropTypes(element) {
2243 {
2244 var type = element.type;
2245
2246 if (type === null || type === undefined || typeof type === 'string') {
2247 return;
2248 }
2249
2250 var propTypes;
2251
2252 if (typeof type === 'function') {
2253 propTypes = type.propTypes;
2254 } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
2255 // Inner props are checked in the reconciler.
2256 type.$$typeof === REACT_MEMO_TYPE)) {
2257 propTypes = type.propTypes;
2258 } else {
2259 return;
2260 }
2261
2262 if (propTypes) {
2263 // Intentionally inside to avoid triggering lazy initializers:
2264 var name = getComponentNameFromType(type);
2265 checkPropTypes(propTypes, element.props, 'prop', name, element);
2266 } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
2267 propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
2268
2269 var _name = getComponentNameFromType(type);
2270
2271 error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
2272 }
2273
2274 if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
2275 error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
2276 }
2277 }
2278 }
2279 /**
2280 * Given a fragment, validate that it can only be provided with fragment props
2281 * @param {ReactElement} fragment

Callers 2

Calls 3

getComponentNameFromTypeFunction · 0.70
checkPropTypesFunction · 0.70
errorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…