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

displayName is not populated during transformation of React.createClass #24

Closed
joshuahhh opened this issue Sep 21, 2015 · 2 comments
Closed

Comments

@joshuahhh
Copy link

Before react-transform

babel.transform('var Component = React.createClass({fun: "yay"});');

generates

"use strict";

var Component = React.createClass({
  displayName: "Component",
  fun: "yay" });

(which includes the populated displayName).

After react-transform

babel.transform('var Component = React.createClass({fun: "yay"});', {
    plugins: ['react-transform'],
    extra: {
        'react-transform': []
    }
});

generates

"use strict";

var _components = {
  _$Unknown: {}
};

function _wrapComponent(uniqueId) {
  return function (ReactClass) {
    return ReactClass;
  };
}

var Component = _wrapComponent("_$Unknown")(React.createClass({ fun: "yay" }));

(which does not have a displayName).

Using this latter code, dev tools can't get a name for Component.

Is this expected? Am I missing something? Thanks!

Versions

@gaearon
Copy link
Owner

gaearon commented Sep 21, 2015

https://github.com/gaearon/babel-plugin-react-transform#limitations:

When using React.createClass() and allowing babel to extract the displayName property you must ensure that babel-plugin-react-display-name is included before react-transform. See this github issue for more details.

@gaearon gaearon closed this as completed Sep 21, 2015
@joshuahhh
Copy link
Author

Ah, I see. That makes sense now. Thanks for the help!

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

2 participants