The following will trigger prop-types rule. As is shown, I'm accessing a second level property of a props value which shouldn't trigger prop-types error.
handleSubmit(e) {
e.preventDefault();
const props = this.props;
let valid = true;
checkValidity.forEach((prop) => {
// if value exist, check if it is valid
if (props[prop].value && props[prop].type !== 'boolean') {
valid = valid && !!props[prop].valid;
}
});
Error goes away if I change props to foo .
handleSubmit(e) {
e.preventDefault();
const foo = this.props;
let valid = true;
checkValidity.forEach((prop) => {
// if value exist, check if it is valid
if (foo[prop].value && foo[prop].type !== 'boolean') {
valid = valid && !!foo[prop].valid;
}
});
Using
[email protected]
[email protected]
[email protected]