Skip to content

Commit

Permalink
propTypes are optional for native components
Browse files Browse the repository at this point in the history
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
  • Loading branch information
elicwhite authored and facebook-github-bot committed Mar 8, 2018
1 parent 49396aa commit dbdf43b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Libraries/ReactNative/verifyPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type ComponentInterface =
| {
name?: string,
displayName?: string,
propTypes: Object,
propTypes?: Object,
};

function verifyPropTypes(
Expand All @@ -41,7 +41,7 @@ function verifyPropTypes(
componentInterface.propTypes;

if (!propTypes) {
throw new Error('`' + componentName + '` has no propTypes defined`');
return;
}

var nativeProps = viewConfig.NativeProps;
Expand Down

0 comments on commit dbdf43b

Please sign in to comment.