Skip to content

Commit 4e1dd9a

Browse files
committed
[Tests] no-unused-prop-types: add passing test
Closes #1561
1 parent 06bbf28 commit 4e1dd9a

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/lib/rules/no-unused-prop-types.js

+31
Original file line numberDiff line numberDiff line change
@@ -3903,6 +3903,37 @@ ruleTester.run('no-unused-prop-types', rule, {
39033903
`,
39043904
features: ['class fields', 'types'],
39053905
},
3906+
{
3907+
code: `
3908+
class Test extends Component<{}, {selectedId: string}> {
3909+
constructor(props: *) {
3910+
super(props);
3911+
this.state = {
3912+
selectedId: '',
3913+
};
3914+
}
3915+
3916+
onChange = ({id}: {id: string}) => { // This will say: 'id' PropType is defined but prop is never used (react/no-unused-prop-types)
3917+
this.setState({
3918+
selectedId: id,
3919+
});
3920+
};
3921+
3922+
render() {
3923+
const {selectedId} = this.state;
3924+
return (
3925+
<div>
3926+
{selectedId}
3927+
<select onChange={() => this.onChange({id: '1'})}>
3928+
<option value='1'>1</option>
3929+
</select>
3930+
</div>
3931+
);
3932+
}
3933+
}
3934+
`,
3935+
features: ['class fields', 'types'],
3936+
},
39063937
]),
39073938

39083939
invalid: parsers.all([].concat(

0 commit comments

Comments
 (0)