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

Added support for resolving exported components within HOCs #124

Merged
merged 1 commit into from
Sep 22, 2016

Conversation

rtsao
Copy link
Contributor

@rtsao rtsao commented Sep 14, 2016

Fixes #80

@rtsao rtsao mentioned this pull request Sep 14, 2016
@rtsao
Copy link
Contributor Author

rtsao commented Sep 14, 2016

FWIW I've signed the CLA (as seen on #71) but I'm not sure why it isn't showing up here

@fkling
Copy link
Member

fkling commented Sep 14, 2016

but I'm not sure why it isn't show up here

The reactjs org is not managed by Facebook anymore afaik.

*/

import recast from 'recast';
import isReactCreateClassCall from './isReactCreateClassCall';
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@fkling
Copy link
Member

fkling commented Sep 22, 2016

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants