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

Function validatePropTypes

dash/deps/react@16.14.0.js:1882–1917  ·  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

1880
1881
1882 function validatePropTypes(element) {
1883 {
1884 var type = element.type;
1885
1886 if (type === null || type === undefined || typeof type === 'string') {
1887 return;
1888 }
1889
1890 var name = getComponentName(type);
1891 var propTypes;
1892
1893 if (typeof type === 'function') {
1894 propTypes = type.propTypes;
1895 } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
1896 // Inner props are checked in the reconciler.
1897 type.$$typeof === REACT_MEMO_TYPE)) {
1898 propTypes = type.propTypes;
1899 } else {
1900 return;
1901 }
1902
1903 if (propTypes) {
1904 setCurrentlyValidatingElement(element);
1905 checkPropTypes_1(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum);
1906 setCurrentlyValidatingElement(null);
1907 } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
1908 propTypesMisspellWarningShown = true;
1909
1910 error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
1911 }
1912
1913 if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
1914 error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
1915 }
1916 }
1917 }
1918 /**
1919 * Given a fragment, validate that it can only be provided with fragment props
1920 * @param {ReactElement} fragment

Callers 2

Calls 3

getComponentNameFunction · 0.70
errorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…