Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #66 #99

Merged
merged 3 commits into from
May 31, 2017
Merged

Fix issue #66 #99

merged 3 commits into from
May 31, 2017

Conversation

mhaas
Copy link
Contributor

@mhaas mhaas commented May 31, 2017

Any function containing a react component is considered a functional
React component by isFunctionalReactComponent().

This leads to false positives for functions which just use or generate
instances of React components. These factory functions do not
follow the general contract of react components. In particular, the
first argument to the function may not be props.

It is hard to detect these cases in isFunctionalReactComponent. Instead,
we relax the sanity check in getPropsForTypeAnnotation: if a typeAnnotation
exists but does not have the type we expect, we do not fail hard.
We just don't generate proptypes.

Not sure if this is the best way to go about this, but it's a start.

Michael Haas added 3 commits May 31, 2017 06:45
Any function containing a react component is considered a functional
React component by isFunctionalReactComponent().

This leads to false positives for functions which just use or generate
instances of React components. These factory functions do not
follow the general contract of react components. In particular, the
first argument to the function may not be props.

It is hard to detect these cases in isFunctionalReactComponent. Instead,
we relax the sanity check in getPropsForTypeAnnotation: if a typeAnnotation
exists but does not have the type we expect, we do not fail hard.
We just don't generate proptypes.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 93.599% when pulling 35867b5 on mhaas:issue-66 into 0bce70b on brigand:master.

@brigand brigand merged commit 65c2402 into brigand:master May 31, 2017
@brigand
Copy link
Owner

brigand commented May 31, 2017

Thanks! Published as 3.1.3.

Mayank1791989 pushed a commit to Mayank1791989/babel-plugin-flow-react-proptypes that referenced this pull request Jul 21, 2017
* Fix issue brigand#66

Any function containing a react component is considered a functional
React component by isFunctionalReactComponent().

This leads to false positives for functions which just use or generate
instances of React components. These factory functions do not
follow the general contract of react components. In particular, the
first argument to the function may not be props.

It is hard to detect these cases in isFunctionalReactComponent. Instead,
we relax the sanity check in getPropsForTypeAnnotation: if a typeAnnotation
exists but does not have the type we expect, we do not fail hard.
We just don't generate proptypes.

* Add missing changelog for 3.1.2

* Add changelog entry for brigand#66
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants