Skip to content
This repository has been archived by the owner on Apr 9, 2020. It is now read-only.

Ember objects detected as react components #81

Closed
mattijauhiainen opened this issue Feb 1, 2016 · 5 comments
Closed

Ember objects detected as react components #81

mattijauhiainen opened this issue Feb 1, 2016 · 5 comments

Comments

@mattijauhiainen
Copy link

react-transform seems to mistake ember objects with render method as react components. A testcase with few examples of typical syntax. Changing the method name to _render 'fixes' the test. mattijauhiainen@dbfbf5d

@nfcampos
Copy link
Collaborator

I'm guessing this does not do what we want?
https://github.com/babel/babel/blob/master/packages/babel-types/src/react.js#L5

Also, I'm not really familiar with developing babel plugins but if it were possible to inspect the prototype of an object it would be quite trivial to identify react components no?

@gaearon
Copy link
Owner

gaearon commented Feb 18, 2016

@nfcampos

I don’t think we use that function.
No, we can’t inspect the prototype because this is compile time, not run time.
I think the bug, if there is one, is somewhere here:

return !!find(patterns, pattern => {
return (
t.isIdentifier(path.node, { name: pattern }) ||
path.matchesPattern(pattern)
);

@gaearon
Copy link
Owner

gaearon commented Feb 18, 2016

Or, rather, the problem is most likely that these two lines should end with || rather than &&:

!matchesPatterns(path.get('superClass'), this.superClasses) &&

!matchesPatterns(path.get('callee'), this.factoryMethods) &&

Please feel free to submit a fix, add tests for it, and I’ll be happy to merge.

@gaearon
Copy link
Owner

gaearon commented Feb 18, 2016

Closing as duplicate of #84. (This one is earlier but the other one describes the problem more accurately).

@gaearon
Copy link
Owner

gaearon commented Mar 4, 2016

Should be fixed in 2.0.1.

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

No branches or pull requests

3 participants