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 read property length of undefined in jsx-handler-names #340

Closed
lencioni opened this issue Nov 30, 2015 · 1 comment
Closed

Cannot read property length of undefined in jsx-handler-names #340

lencioni opened this issue Nov 30, 2015 · 1 comment

Comments

@lencioni
Copy link
Collaborator

Hi! Using 3.11.1 I just tried enabling jsx-handler-names with the following configuration:

'react/jsx-handler-names': [2, {
  'eventHandlerPrefix': 'handle',
  'eventHandlerPropPrefix': 'on',
}]

And I got the following error:

/path/to/node_modules/eslint-plugin-react/lib/rules/jsx-handler-names.js:32
    if (propertyName.length) {
                    ^

TypeError: Cannot read property 'length' of undefined
    at rebuildPropValue (/path/to/node_modules/eslint-plugin-react/lib/rules/jsx-handler-names.js:32:21)
    at EventEmitter.JSXAttribute (/path/to/node_modules/eslint-plugin-react/lib/rules/jsx-handler-names.js:50:23)
    at emitOne (events.js:82:20)
    at EventEmitter.emit (events.js:169:7)
    at NodeEventGenerator.enterNode (/path/to/node_modules/eslint/lib/util/node-event-generator.js:42:22)
    at CommentEventGenerator.enterNode (/path/to/node_modules/eslint/lib/util/comment-event-generator.js:98:23)
    at Controller.controller.traverse.enter (/path/to/node_modules/eslint/lib/eslint.js:767:36)
    at Controller.__execute (/path/to/node_modules/estraverse/estraverse.js:397:31)
    at Controller.traverse (/path/to/node_modules/estraverse/estraverse.js:495:28)
    at EventEmitter.module.exports.api.verify (/path/to/node_modules/eslint/lib/eslint.js:764:24)

I'm not really sure what the JS looks like that it is blowing up on, but I figured I'd post this here to start with.

@lencioni
Copy link
Collaborator Author

Alright, here's a repro case. It seems to happen when a prop is a property of an item of an array:

const Test = React.createClass({
  render() {
    return (
      <Something
        myProp={arr[0].prop}
      />
    );
  }
});

module.exports = Test;

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

No branches or pull requests

2 participants