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

Declaring propTypes on a non-component object throws #1934

Closed
alexlrobertson opened this issue Aug 14, 2018 · 1 comment
Closed

Declaring propTypes on a non-component object throws #1934

alexlrobertson opened this issue Aug 14, 2018 · 1 comment

Comments

@alexlrobertson
Copy link

Imported.js

const PropTypes = require('prop-types');

const Imported = () => {
  return null;
};

Imported.propTypes = {};

module.exports = Imported.

Components.js

const Imported = require('./Imported');

const Components = {
  AComponent: (props) => <Imported {...props} />
};

Components.propTypes = Imported.propTypes;

module.exports = Components;
Cannot read property 'name' of undefined
TypeError: Cannot read property 'name' of undefined
    at markPropTypesAsDeclared (/Users/arobert3/Sites/eslint-bug/node_modules/eslint-plugin-react/lib/util/propTypes.js:475:51)
    at Object.MemberExpression (/Users/arobert3/Sites/eslint-bug/node_modules/eslint-plugin-react/lib/util/propTypes.js:644:9)
    at updatedRuleInstructions.(anonymous function) (/Users/arobert3/Sites/eslint-bug/node_modules/eslint-plugin-react/lib/util/Components.js:706:43)
    at listeners.(anonymous function).forEach.listener (/Users/arobert3/Sites/eslint-bug/node_modules/eslint/lib/util/safe-emitter.js:45:58)
    at Array.forEach (<anonymous>)
    at Object.emit (/Users/arobert3/Sites/eslint-bug/node_modules/eslint/lib/util/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/Users/arobert3/Sites/eslint-bug/node_modules/eslint/lib/util/node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (/Users/arobert3/Sites/eslint-bug/node_modules/eslint/lib/util/node-event-generator.js:280:22)
    at NodeEventGenerator.enterNode (/Users/arobert3/Sites/eslint-bug/node_modules/eslint/lib/util/node-event-generator.js:294:14)
    at CodePathAnalyzer.enterNode (/Users/arobert3/Sites/eslint-bug/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:632:23)
@ljharb
Copy link
Member

ljharb commented Aug 14, 2018

Fixed by #1932, duplicate of #1928.

@ljharb ljharb closed this as completed Aug 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants