Skip to content

Commit bad47d6

Browse files
committed
Fix prop-types to correcly assign props to components (fixes #991)
1 parent 13806f1 commit bad47d6

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/rules/prop-types.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ module.exports = {
586586
}
587587

588588
var component = components.get(utils.getParentComponent());
589-
var usedPropTypes = component && component.usedPropTypes || [];
589+
var usedPropTypes = (component && component.usedPropTypes || []).slice();
590590

591591
switch (type) {
592592
case 'direct':

tests/lib/rules/prop-types.js

+13
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,19 @@ ruleTester.run('prop-types', rule, {
14151415
jsx: true
14161416
}
14171417
}
1418+
}, {
1419+
code: [
1420+
'export class Example extends Component {',
1421+
' static propTypes = {',
1422+
' onDelete: React.PropTypes.func.isRequired',
1423+
' }',
1424+
' handleDeleteConfirm = () => {',
1425+
' this.props.onDelete();',
1426+
' };',
1427+
' handleSubmit = async ({certificate, key}) => {};',
1428+
'}'
1429+
].join('\n'),
1430+
parser: 'babel-eslint'
14181431
}
14191432
],
14201433

0 commit comments

Comments
 (0)