Skip to content

Warning: This JSX uses a plain function. Only React components are valid in React's JSX transform.  #2436

@TrySpace

Description

@TrySpace

I just updated to React 0.12.0, and now a mass of warnings flood my console:

  Warning: This JSX uses a plain function. Only React components are valid in React's JSX transform. 

It seems to have to do with which elements I'm using, and the only thing that seems to fix it is by re-building imported ( var Button = React.createFactory(require('./button')) ) like:

    var ButtonComponent = React.createClass({
      render: function() {
        return Button({ });
      }
    });

But I think that's rather unnecessary and think this is not the purpose of the update, and I thought that .createFactory would be enough for imported components, but it's not. I do use browserify if that helps.

So I can create new elements fine with createElement for example, without warnings, but when I try to RE-USE elements, which is exactly why we all want to use React... It warns me..

In a few cases it gave me the specific element name that wasn't right, but that was fixed by putting .createFactory before require()..

I am working in jsx, which is auto compiled through gulp-jsx, I think that's updated (2.0.0), because I don't need the @jsx tags anymore..

The warning does not give me anything to trace as well, but I pinpointed it to happening in each render method of components (elements?) that re-use either imported ones, or others in the same file/scope/module.
So like:

 render: function(){
      return(
         <div>
           <h2>This works fine </h2>
           <Button title="Gives warning, but not when removed" />
        </div>
      )
     }

Anyone can say what I'm missing here? It can't be the purpose, to be forced to give your imported elements a different name (because assigning the same Variable name to the createClass as the require'd one will throw the same warning.)

What does it mean with 'components are valid', it is valid, it is React.

I can't find that much about what is meant with 'Plain functions' it is mentioned once in one of the blog updates. I tried making my existing components, through the new methods, but warnings persist.

What is exactly needed (barebones) to avoid these warnings, and will it ever break my app in new updates? I came from I 0.11, where everything worked fine.. So the transition should be that big.. I must be missing some essential thing here...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions