wyze / babel-plugin-transform-react-stateless-component-name

Adds a display name to the stateless component in the React Dev Tools.
MIT License
32 stars 8 forks source link

Support ternary operator #6

Closed dlineberger closed 7 years ago

dlineberger commented 7 years ago

I have ES6 code that looks similar to this:

const foo = _.isEmpty(bar) ? null : <div />

The transform-react-stateless-component-name plugin adds a

foo.displayName = 'foo';

line to the transpiled code, but this obviously causes a runtime exception when foo is null.

wyze commented 7 years ago

Hi @dlineberger, I added the code you provided as a test case and the test pass, so it didn't try to assign it a displayName property. Is there more information that you could provide?

wyze commented 7 years ago

Closing as there has been no activity for a while. I am more than happy to reopen if it is still an issue.