2015-04-17 01:17:19 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2015-04-17 01:17:19 +00:00
|
|
|
*
|
2017-09-25 05:57:35 +00:00
|
|
|
* @format
|
2018-05-07 23:45:19 +00:00
|
|
|
* @flow
|
2015-04-17 01:17:19 +00:00
|
|
|
*/
|
|
|
|
|
2018-05-07 23:45:19 +00:00
|
|
|
'use strict';
|
2015-04-17 01:17:19 +00:00
|
|
|
|
2018-05-07 23:45:19 +00:00
|
|
|
const ReactNativeStyleAttributes = require('ReactNativeStyleAttributes');
|
2015-07-25 01:31:55 +00:00
|
|
|
|
2015-04-17 01:17:19 +00:00
|
|
|
function verifyPropTypes(
|
2018-05-07 23:45:19 +00:00
|
|
|
viewConfig: $ReadOnly<{
|
|
|
|
NativeProps: $ReadOnly<{
|
|
|
|
[propName: string]: mixed,
|
|
|
|
}>,
|
|
|
|
propTypes: ?$ReadOnly<{
|
|
|
|
[propName: string]: mixed,
|
|
|
|
}>,
|
|
|
|
uiViewClassName: string,
|
|
|
|
}>,
|
|
|
|
nativePropsToIgnore: ?$ReadOnly<{
|
|
|
|
[propName: string]: boolean,
|
|
|
|
}>,
|
2015-04-17 01:17:19 +00:00
|
|
|
) {
|
2018-05-07 23:45:19 +00:00
|
|
|
const {NativeProps, propTypes, uiViewClassName} = viewConfig;
|
2017-03-28 18:17:21 +00:00
|
|
|
|
2018-05-07 23:45:19 +00:00
|
|
|
if (propTypes == null) {
|
2018-03-08 23:43:23 +00:00
|
|
|
return;
|
2015-05-18 18:53:23 +00:00
|
|
|
}
|
|
|
|
|
2018-05-07 23:45:19 +00:00
|
|
|
for (const propName in NativeProps) {
|
2017-09-25 05:57:35 +00:00
|
|
|
if (
|
2018-05-07 23:45:19 +00:00
|
|
|
propTypes[propName] ||
|
|
|
|
ReactNativeStyleAttributes[propName] ||
|
|
|
|
(nativePropsToIgnore && nativePropsToIgnore[propName])
|
2017-09-25 05:57:35 +00:00
|
|
|
) {
|
2018-05-07 23:45:19 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
const prettyName = `${uiViewClassName}.${propName}`;
|
|
|
|
const nativeType = String(NativeProps[propName]);
|
|
|
|
const suggestion =
|
|
|
|
'\n\nIf you have not changed this prop yourself, this usually means ' +
|
|
|
|
'that the versions of your native and JavaScript code are out of sync. ' +
|
|
|
|
'Updating both should make this error go away.';
|
|
|
|
|
|
|
|
if (propTypes.hasOwnProperty(propName)) {
|
|
|
|
console.error(
|
|
|
|
`Invalid propType to configure \`${prettyName}\` (${nativeType}).` +
|
|
|
|
suggestion,
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
console.error(
|
|
|
|
`Missing a propType to configure \`${prettyName}\` (${nativeType}).` +
|
|
|
|
suggestion,
|
|
|
|
);
|
2015-04-17 01:17:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = verifyPropTypes;
|