Eslint-plugin-react: no-children-prop: Cannot read property 'name' of undefined

Created on 26 Sep 2016  路  8Comments  路  Source: yannickcr/eslint-plugin-react

version: 6.3.0

Cannot read property 'name' of undefined
TypeError: Cannot read property 'name' of undefined
    at /Users/myabc/git/myproj/node_modules/eslint-plugin-react/lib/rules/no-children-prop.js:57:26
    at Array.find (native)
    at EventEmitter.CallExpression (/Users/myabc/git/myproj/node_modules/eslint-plugin-react/lib/rules/no-children-prop.js:56:34)
    at emitOne (events.js:101:20)
    at EventEmitter.emit (events.js:188:7)
    at NodeEventGenerator.enterNode (/Users/myabc/git/myproj/node_modules/eslint/lib/util/node-event-generator.js:40:22)
    at CodePathAnalyzer.enterNode (/Users/myabc/git/myproj/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:608:23)
    at CommentEventGenerator.enterNode (/Users/myabc/git/myproj/node_modules/eslint/lib/util/comment-event-generator.js:97:23)
    at Controller.enter (/Users/myabc/git/myproj/node_modules/eslint/lib/eslint.js:918:36)
    at Controller.__execute (/Users/myabc/git/myproj/node_modules/eslint/node_modules/estraverse/estraverse.js:397:31)

Error code:

export class CustomLayout extends React.Component {
  static propTypes = {
    children: React.PropTypes.node,
    elementType: React.PropTypes.oneOf(['ul', 'div']),
  };

  render() {
    const { children, ...restProps } = this.props;
    return React.createElement(
      this.props.elementType,
      {
        ref: node => (this.dom = node),
        ...restProps,
      },
      this.props.children
    );
  }
}

Most helpful comment

All 8 comments

Getting the same issue with a similar (simple) code.

Yeah, a tag would be nice :P Ran into the same issue.

Same thing for style-prop-object?

I don't have the issue locally but have the error when running on circleci.. Not sure to know why :/

@kouhin can you confirm if the issue is still present on v6.4.1?

Confirmed it works with 6.4.1. My CI was using an old version from the cache.

@ljharb Confirmed with 6.4.1! Thanks

Was this page helpful?
0 / 5 - 0 ratings