From dbdf43b428da19a9eba012753904bcf33339ea9a Mon Sep 17 00:00:00 2001 From: Eli White Date: Thu, 8 Mar 2018 15:43:23 -0800 Subject: [PATCH] propTypes are optional for native components Summary: We plan to migrate native components like View, Text, and Image to be typed with Flow instead of propTypes so that we can better enforce our usages. This change makes it so that *if* propTypes are defined they must cover the native props. However, if they aren't specified, the validation doesn't occur. Eventually, the prop validation should occur via codegen that generates an interface the native component must implement from the flow types defined in JS. Reviewed By: yungsters Differential Revision: D7203649 fbshipit-source-id: a8095aa46807ce03272e2962289e8f5705b422b9 --- Libraries/ReactNative/verifyPropTypes.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Libraries/ReactNative/verifyPropTypes.js b/Libraries/ReactNative/verifyPropTypes.js index 30d29f200ad..7791899d298 100644 --- a/Libraries/ReactNative/verifyPropTypes.js +++ b/Libraries/ReactNative/verifyPropTypes.js @@ -17,7 +17,7 @@ export type ComponentInterface = | { name?: string, displayName?: string, - propTypes: Object, + propTypes?: Object, }; function verifyPropTypes( @@ -41,7 +41,7 @@ function verifyPropTypes( componentInterface.propTypes; if (!propTypes) { - throw new Error('`' + componentName + '` has no propTypes defined`'); + return; } var nativeProps = viewConfig.NativeProps;