Skip to content

Commit dbdf43b

Browse files
elicwhitefacebook-github-bot
authored andcommitted
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
1 parent 49396aa commit dbdf43b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Libraries/ReactNative/verifyPropTypes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export type ComponentInterface =
1717
| {
1818
name?: string,
1919
displayName?: string,
20-
propTypes: Object,
20+
propTypes?: Object,
2121
};
2222

2323
function verifyPropTypes(
@@ -41,7 +41,7 @@ function verifyPropTypes(
4141
componentInterface.propTypes;
4242

4343
if (!propTypes) {
44-
throw new Error('`' + componentName + '` has no propTypes defined`');
44+
return;
4545
}
4646

4747
var nativeProps = viewConfig.NativeProps;

0 commit comments

Comments
 (0)