PropTypes simply validates parameters and does not throw uncaught exceptions. So regardless of whether the validation is successful or not, the props passes in the component, but prompts a warning.
function updateClassComponent(
current: Fiber | null,
workInProgress: Fiber,
Component: any,
nextProps,
renderExpirationTime: ExpirationTime
) {
if (__DEV__) {
if (workInProgress.type !== workInProgress.elementType) {
const innerPropTypes = Component.propTypes
if (innerPropTypes) {
checkPropTypes(
innerPropTypes,
nextProps, // Resolved props
"prop",
getComponentName(Component),
getCurrentFiberStackInDev
)
}
}
}
...
}
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
if (process.env.NODE_ENV !== "production") {
for (var typeSpecName in typeSpecs) {
if (has(typeSpecs, typeSpecName)) {
var error
try {
if (typeof typeSpecs[typeSpecName] !== "function") {
var err = Error("...TypeError...")
err.name = "Invariant Violation"
throw err
}
error = typeSpecs[typeSpecName](
values,
typeSpecName,
componentName,
location,
null,
ReactPropTypesSecret
)
} catch (ex) {
error = ex
}
if (error && !(error instanceof Error)) {
printWarning(error)
}
}
}
}
}
And for the sake of performance, prop-types validation is done only in dev mode. No processing will be done in the production environment.