better error message for `propTypes` check
Summary: When you did a typo in declaring a prop type (like using `boolean` insteal of `bool`) you'd got a bit misleading error message: {F27113768} The truth is that the prop type is defined, but not correctly. So I've changed the message in this case to be more accurate: {F27113627} public Reviewed By: sahrens Differential Revision: D2729340 fb-gh-sync-id: dd12c10a4f3a1c9825293f86481a082908127a76
This commit is contained in:
parent
8d397b4cbc
commit
14478f6701
|
@ -41,11 +41,16 @@ function verifyPropTypes(
|
||||||
if (!componentInterface.propTypes[prop] &&
|
if (!componentInterface.propTypes[prop] &&
|
||||||
!ReactNativeStyleAttributes[prop] &&
|
!ReactNativeStyleAttributes[prop] &&
|
||||||
(!nativePropsToIgnore || !nativePropsToIgnore[prop])) {
|
(!nativePropsToIgnore || !nativePropsToIgnore[prop])) {
|
||||||
throw new Error(
|
var message;
|
||||||
'`' + componentName + '` has no propType for native prop `' +
|
if (componentInterface.propTypes.hasOwnProperty(prop)) {
|
||||||
|
message = '`' + componentName + '` has incorrectly defined propType for native prop `' +
|
||||||
|
viewConfig.uiViewClassName + '.' + prop + '` of native type `' + nativeProps[prop];
|
||||||
|
} else {
|
||||||
|
message = '`' + componentName + '` has no propType for native prop `' +
|
||||||
viewConfig.uiViewClassName + '.' + prop + '` of native type `' +
|
viewConfig.uiViewClassName + '.' + prop + '` of native type `' +
|
||||||
nativeProps[prop] + '`'
|
nativeProps[prop] + '`';
|
||||||
);
|
};
|
||||||
|
throw new Error(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue