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

Cannot parse HTML to JSX without using outputClassName #21

Closed
alansouzati opened this issue Mar 23, 2015 · 1 comment
Closed

Cannot parse HTML to JSX without using outputClassName #21

alansouzati opened this issue Mar 23, 2015 · 1 comment

Comments

@alansouzati
Copy link
Contributor

Hi,

Great job on react-magic. I'm trying to use this component with the following option:

{
   createClass: true
}

I would expect the following output:

"React.createClass..."

but it turns out to be

"var NewComponent = React.createClass...."

I see in the code that the config outputClassName is optional. In the convert function we have:

  if (this.config.createClass) {
      if (this.config.outputClassName) {
        this.output = 'var ' + this.config.outputClassName + ' = React.createClass({\n';
      } else { // this is the callback i was expecting to be called
        this.output = 'React.createClass({\n';
      }
      this.output += this.config.indent + 'render: function() {' + "\n";
      this.output += this.config.indent + this.config.indent + 'return (\n';
 }

But in the object constructor there is always a fallback to 'NewComponent', from the source-code:

var HTMLtoJSX = function(config) {
  this.config = config || {};

  if (this.config.createClass === undefined) {
    this.config.createClass = true;
  }
  if (!this.config.indent) {
    this.config.indent = '  ';
  }
  if (!this.config.outputClassName) { // I would not expect to have this line in place.
    this.config.outputClassName = 'NewComponent';
  }
};
@alansouzati alansouzati changed the title Cannot parser HTML to JSX without using outputClassName Cannot parse HTML to JSX without using outputClassName Mar 23, 2015
@Daniel15
Copy link
Member

Fixed by #22

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

No branches or pull requests

2 participants