Skip to content

Commit d54f1a4

Browse files
committed
Fix case where props were not assigned to the right component (fixes #485)
1 parent 70cebe4 commit d54f1a4

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/util/Components.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ Components.prototype.list = function() {
8585
if (!this._list.hasOwnProperty(i) || this._list[i].confidence >= 2) {
8686
continue;
8787
}
88-
var component;
89-
var node;
88+
var component = null;
89+
var node = null;
9090
node = this._list[i].node;
9191
while (!component && node.parent) {
9292
node = node.parent;

tests/lib/rules/prop-types.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2006,6 +2006,18 @@ ruleTester.run('prop-types', rule, {
20062006
errors: [{
20072007
message: '\'test\' is missing in props validation'
20082008
}]
2009+
}, {
2010+
code: [
2011+
'const TestComponent = props =>',
2012+
' <div onClick={() => props.test()} />',
2013+
'const mapStateToProps = (_, props) => ({',
2014+
' otherProp: props.otherProp,',
2015+
'})'
2016+
].join('\n'),
2017+
parserOptions: parserOptions,
2018+
errors: [{
2019+
message: '\'test\' is missing in props validation'
2020+
}]
20092021
}
20102022
]
20112023
});

0 commit comments

Comments
 (0)