mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-26 05:15:49 +08:00
[ReactNative] cleanup native components
This commit is contained in:
@@ -14,16 +14,24 @@
|
||||
var ReactNativeStyleAttributes = require('ReactNativeStyleAttributes');
|
||||
var View = require('View');
|
||||
|
||||
export type ComponentInterface = ReactClass<any, any, any> | {
|
||||
name?: string;
|
||||
displayName?: string;
|
||||
propTypes: Object;
|
||||
};
|
||||
|
||||
function verifyPropTypes(
|
||||
component: Function,
|
||||
componentInterface: ComponentInterface,
|
||||
viewConfig: Object,
|
||||
nativePropsToIgnore?: Object
|
||||
nativePropsToIgnore?: ?Object
|
||||
) {
|
||||
if (!viewConfig) {
|
||||
return; // This happens for UnimplementedView.
|
||||
}
|
||||
var componentName = component.name || component.displayName;
|
||||
if (!component.propTypes) {
|
||||
var componentName = componentInterface.name ||
|
||||
componentInterface.displayName ||
|
||||
'unknown';
|
||||
if (!componentInterface.propTypes) {
|
||||
throw new Error(
|
||||
'`' + componentName + '` has no propTypes defined`'
|
||||
);
|
||||
@@ -31,7 +39,7 @@ function verifyPropTypes(
|
||||
|
||||
var nativeProps = viewConfig.NativeProps;
|
||||
for (var prop in nativeProps) {
|
||||
if (!component.propTypes[prop] &&
|
||||
if (!componentInterface.propTypes[prop] &&
|
||||
!View.propTypes[prop] &&
|
||||
!ReactNativeStyleAttributes[prop] &&
|
||||
(!nativePropsToIgnore || !nativePropsToIgnore[prop])) {
|
||||
|
||||
Reference in New Issue
Block a user