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

display-name false negative with React.createClass and ES6-style method #852

Closed
peet opened this issue Sep 19, 2016 · 0 comments
Closed
Labels

Comments

@peet
Copy link
Contributor

peet commented Sep 19, 2016

I initially raised #650 because I had many components not reporting display-name issues when being assigned directly to module.exports (and ending up with 'exports' as the name in the devtools).

I've since done some for investivation and narrowed it down to using React.createClass() passing in an object containing an ES6-style method.

This does not report an error for "react/display-name": "error"

var React = require('react');
module.exports = React.createClass({
  render() {
    return null;
  }
});

or even:

var React = require('react');
module.exports = React.createClass({
  method() {},
  render: function() {
    return null;
  }
});

Further, it has something to do with the method() property having its own 'name', not the whole class, as this also does not trigger the display-name error:

var React = require('react');
module.exports = React.createClass({
  method: function method() {},
  render: function() {
    return null;
  }
});

and

var React = require('react');
module.exports = React.createClass({
  render: function named() {
    return null;
  }
});

eslint-pluign-react: "6.2.2"

example repo peet/display-name-test

@ljharb ljharb added the bug label Sep 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants