oliviertassinari / babel-plugin-transform-react-remove-prop-types

Remove unnecessary React propTypes from the production build. :balloon:
MIT License
897 stars 61 forks source link

Cannot get "name" of undefined #178

Closed tquetano-netflix closed 5 years ago

tquetano-netflix commented 5 years ago

Looks like with the latest release (0.4.22), the check for currentNode.get('callee').node.property.name === 'createClass') fails when there is no node.property. Adding a simple check at this line solves the issue:

return (
  currentNode.get('callee').node.name === globalOptions.createReactClassName ||
  (currentNode.get('callee').node.property && currentNode.get('callee').node.property.name === 'createClass')
)

I'll whip up a PR for the fix.