MCPcopy Create free account
hub / github.com/Lobos/react-ui / createPrimitiveTypeChecker

Function createPrimitiveTypeChecker

docs/lib/react.js:12609–12625  ·  view source on GitHub ↗
(expectedType)

Source from the content-addressed store, hash-verified

12607}
12608
12609function createPrimitiveTypeChecker(expectedType) {
12610 function validate(props, propName, componentName, location, propFullName) {
12611 var propValue = props[propName];
12612 var propType = getPropType(propValue);
12613 if (propType !== expectedType) {
12614 var locationName = ReactPropTypeLocationNames[location];
12615 // `propValue` being instance of, say, date/regexp, pass the 'object'
12616 // check, but we can offer a more precise error message here rather than
12617 // 'of type `object`'.
12618 var preciseType = getPreciseType(propValue);
12619
12620 return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
12621 }
12622 return null;
12623 }
12624 return createChainableTypeChecker(validate);
12625}
12626
12627function createAnyTypeChecker() {
12628 return createChainableTypeChecker(emptyFunction.thatReturns(null));

Callers 1

react.jsFile · 0.85

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…