Skip to content

Commit

Permalink
Fix case where props were not assigned to the right component (fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed Mar 6, 2016
1 parent 70cebe4 commit d54f1a4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/util/Components.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ Components.prototype.list = function() {
if (!this._list.hasOwnProperty(i) || this._list[i].confidence >= 2) {
continue;
}
var component;
var node;
var component = null;
var node = null;
node = this._list[i].node;
while (!component && node.parent) {
node = node.parent;
Expand Down
12 changes: 12 additions & 0 deletions tests/lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -2006,6 +2006,18 @@ ruleTester.run('prop-types', rule, {
errors: [{
message: '\'test\' is missing in props validation'
}]
}, {
code: [
'const TestComponent = props =>',
' <div onClick={() => props.test()} />',
'const mapStateToProps = (_, props) => ({',
' otherProp: props.otherProp,',
'})'
].join('\n'),
parserOptions: parserOptions,
errors: [{
message: '\'test\' is missing in props validation'
}]
}
]
});

0 comments on commit d54f1a4

Please sign in to comment.