mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-26 13:25:51 +08:00
Enabled pretier (@format) for all files in ReactNative folder
Reviewed By: mmmulani Differential Revision: D5894100 fbshipit-source-id: fae0d02547c0f049fc77f87f209b2ae4f2a298fd
This commit is contained in:
committed by
Facebook Github Bot
parent
7e5d4335ca
commit
8606e04c5d
@@ -8,29 +8,30 @@
|
||||
*
|
||||
* @providesModule verifyPropTypes
|
||||
* @flow
|
||||
* @format
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var ReactNativeStyleAttributes = require('ReactNativeStyleAttributes');
|
||||
|
||||
export type ComponentInterface = React$ComponentType<any> | {
|
||||
name?: string,
|
||||
displayName?: string,
|
||||
propTypes: Object,
|
||||
};
|
||||
export type ComponentInterface =
|
||||
| React$ComponentType<any>
|
||||
| {
|
||||
name?: string,
|
||||
displayName?: string,
|
||||
propTypes: Object,
|
||||
};
|
||||
|
||||
function verifyPropTypes(
|
||||
componentInterface: ComponentInterface,
|
||||
viewConfig: Object,
|
||||
nativePropsToIgnore?: ?Object
|
||||
nativePropsToIgnore?: ?Object,
|
||||
) {
|
||||
if (!viewConfig) {
|
||||
return; // This happens for UnimplementedView.
|
||||
}
|
||||
var componentName =
|
||||
componentInterface.displayName ||
|
||||
componentInterface.name ||
|
||||
'unknown';
|
||||
componentInterface.displayName || componentInterface.name || 'unknown';
|
||||
|
||||
// ReactNative `View.propTypes` have been deprecated in favor of
|
||||
// `ViewPropTypes`. In their place a temporary getter has been added with a
|
||||
@@ -38,30 +39,45 @@ function verifyPropTypes(
|
||||
// temporary workaround, __propTypesSecretDontUseThesePlease.
|
||||
// TODO (bvaughn) Revert this particular change any time after April 1
|
||||
var propTypes =
|
||||
(componentInterface : any).__propTypesSecretDontUseThesePlease ||
|
||||
(componentInterface: any).__propTypesSecretDontUseThesePlease ||
|
||||
componentInterface.propTypes;
|
||||
|
||||
if (!propTypes) {
|
||||
throw new Error(
|
||||
'`' + componentName + '` has no propTypes defined`'
|
||||
);
|
||||
throw new Error('`' + componentName + '` has no propTypes defined`');
|
||||
}
|
||||
|
||||
var nativeProps = viewConfig.NativeProps;
|
||||
for (var prop in nativeProps) {
|
||||
if (!propTypes[prop] &&
|
||||
!ReactNativeStyleAttributes[prop] &&
|
||||
(!nativePropsToIgnore || !nativePropsToIgnore[prop])) {
|
||||
if (
|
||||
!propTypes[prop] &&
|
||||
!ReactNativeStyleAttributes[prop] &&
|
||||
(!nativePropsToIgnore || !nativePropsToIgnore[prop])
|
||||
) {
|
||||
var message;
|
||||
if (propTypes.hasOwnProperty(prop)) {
|
||||
message = '`' + componentName + '` has incorrectly defined propType for native prop `' +
|
||||
viewConfig.uiViewClassName + '.' + prop + '` of native type `' + nativeProps[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 `' +
|
||||
nativeProps[prop] + '`';
|
||||
message =
|
||||
'`' +
|
||||
componentName +
|
||||
'` has no propType for native prop `' +
|
||||
viewConfig.uiViewClassName +
|
||||
'.' +
|
||||
prop +
|
||||
'` of native type `' +
|
||||
nativeProps[prop] +
|
||||
'`';
|
||||
}
|
||||
message += '\nIf you haven\'t changed this prop yourself, this usually means that ' +
|
||||
message +=
|
||||
"\nIf you haven't changed this prop yourself, this usually means that " +
|
||||
'your versions of the native code and JavaScript code are out of sync. Updating both ' +
|
||||
'should make this error go away.';
|
||||
throw new Error(message);
|
||||
|
||||
Reference in New Issue
Block a user