-
-
Notifications
You must be signed in to change notification settings - Fork 297
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
Added support for resolving exported components within HOCs #124
Conversation
FWIW I've signed the CLA (as seen on #71) but I'm not sure why it isn't showing up here |
The reactjs org is not managed by Facebook anymore afaik. |
*/ | ||
|
||
import recast from 'recast'; | ||
import isReactCreateClassCall from './isReactCreateClassCall'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about isReactComponentClass
and isStatelessComponent
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
React Classes and stateless functional components are not call expressions, but React.createClass()
is.
|
||
/** | ||
* If the path is a call expression, it recursively resolves to the | ||
* rightmost argument, stopping if it finds a React.createClass call expression |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inspecting only the rightmost argument may not work for all cases.
One common case is for example Relay, where the component will be the first argument.
Also it might be interesting to investigate connect()
of react-redux and recompose, as a baseline for example usage of HoCs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's interesting that Relay doesn't follow the convention I've seen for every other HOC, which is to take only one argument (the component) or have the component be the rightmost argument. Recompose follows this convention.
But as discussed in #80 you can easily turn any HOC into a HOC that takes a component as its only or rightmost argument.
Yeah, looks good to me, I think we can always iterate on it and improve it if necessary. Would be cool to document this behavior though. |
Fixes #80