Reputation: 2264
const propTypes = {
prop1: PropTypes.string,
prop2: PropTypes.string,
prop3: PropTypes.number,
};
const something = (props) => ((props.props2 > 0 & props.prop1 === props.props3) ?
t('translation/abc')
: t('translation/def'));
why does the component throw lint error PropType is defined but prop is never used
for all three props prop1, prop2, prop3
?
Upvotes: 3
Views: 19751
Reputation: 5584
This should fix your problem, let's de-structure your props and then assign propTypes to your stateless component.
const something = ({prop1, prop2, prop3}) => ((props2 > 0 & prop1 === props3)
? t('translation/abc')
: t('translation/def'));
something.propTypes = {
prop1: PropTypes.string,
prop2: PropTypes.string,
prop3: PropTypes.number,
};
Upvotes: 7
Reputation: 823
You are never assigning the propTypes constant to your function, so the props will not be validated against.
If you do
something.propTypes = propTypes;
the linter should accept your code.
Upvotes: 0