wyze / babel-plugin-transform-react-stateless-component-name

Adds a display name to the stateless component in the React Dev Tools.
MIT License
32 stars 8 forks source link

Cannot read property 'length' of undefined on arrow function which does not include React #4

Closed amok closed 7 years ago

amok commented 7 years ago

code

export default () => new Promise(resolve => {
  window.addEventListener('XXX', () => {
    resolve(window.xxx);
  });
});

stack trace

ERROR in ./src/initializeApp2.js
Module build failed: TypeError: /project/src/initializeApp2.js: Cannot read property 'length' of undefined
    at doesReturnJSX (/project/node_modules/babel-plugin-transform-react-stateless-component-name/lib/index.js:33:12)
    at PluginPass.ExportDefaultDeclaration (/project/node_modules/babel-plugin-transform-react-stateless-component-name/lib/index.js:53:15)
    at newFn (/project/node_modules/babel-traverse/lib/visitors.js:276:21)
    at NodePath._call (/project/node_modules/babel-traverse/lib/path/context.js:76:18)
    at NodePath.call (/project/node_modules/babel-traverse/lib/path/context.js:48:17)
    at NodePath.visit (/project/node_modules/babel-traverse/lib/path/context.js:105:12)
    at TraversalContext.visitQueue (/project/node_modules/babel-traverse/lib/context.js:150:16)
    at TraversalContext.visitMultiple (/project/node_modules/babel-traverse/lib/context.js:103:17)
    at TraversalContext.visit (/project/node_modules/babel-traverse/lib/context.js:190:19)
    at Function.traverse.node (/project/node_modules/babel-traverse/lib/index.js:114:17)
    at NodePath.visit (/project/node_modules/babel-traverse/lib/path/context.js:115:19)
    at TraversalContext.visitQueue (/project/node_modules/babel-traverse/lib/context.js:150:16)
    at TraversalContext.visitSingle (/project/node_modules/babel-traverse/lib/context.js:108:19)
    at TraversalContext.visit (/project/node_modules/babel-traverse/lib/context.js:192:19)
    at Function.traverse.node (/project/node_modules/babel-traverse/lib/index.js:114:17)
    at traverse (/project/node_modules/babel-traverse/lib/index.js:79:12)
 @ ./src/entry.js 11:26-57

environment

$ npm version
{ 'project': '1.0.0',
  npm: '4.0.2',
  ares: '1.10.1-DEV',
  cldr: '30.0.2',
  http_parser: '2.7.0',
  icu: '58.1',
  modules: '51',
  node: '7.1.0',
  openssl: '1.0.2j',
  tz: '2016g',
  unicode: '9.0',
  uv: '1.10.0',
  v8: '5.4.500.36',
  zlib: '1.2.8' }
├── babel-cli@6.18.0
├── babel-core@6.18.2
├── babel-eslint@7.1.1
├── babel-loader@6.2.8
├── babel-plugin-add-module-exports@0.2.1
├── babel-plugin-lodash@3.2.10
├── babel-plugin-react-transform@2.0.2
├── babel-plugin-syntax-class-properties@6.13.0
├── babel-plugin-transform-class-properties@6.19.0
├── babel-plugin-transform-react-stateless-component-name@1.0.1
├── babel-plugin-transform-runtime@6.15.0
├── babel-plugin-transform-strict-mode@6.18.0
├── babel-polyfill@6.16.0
├── babel-preset-es2015@6.18.0
├── babel-preset-react@6.16.0
├── babel-preset-stage-0@6.16.0
├── babel-register@6.18.0
├── babel-runtime@6.18.0
wyze commented 7 years ago

Thanks for the report! I'll get a new version released with the fix included.