When using objects as maps (see: https://flow.org/en/docs/types/objects/#toc-objects-as-maps) in props, I seem to be getting 'missing in props validation' errors on all of the keys in the map. Is this intended behaviour or a bug?
type Field = {
value: string,
error: string,
}
type Form = {
fields: {
[string]: Field,
},
formError: string,
}
type Props = {
bankDetails: Form,
onBankDetailsUpdate: any => void,
}
const Provider = (props:Props) =>
...
<Input
label={'Account Name'}
value={props.bankDetails.fields.accountName.value}
{/* bankDetails.fields.accountName is missing in props validation */}
{/* bankDetails.fields.accountName.value is missing in props validation */}
error={props.bankDetails.fields.accountName.error}
{/* bankDetails.fields.accountName is missing in props validation */}
{/* bankDetails.fields.accountName.error is missing in props validation */}
onChange={newVal => props.onBankDetailsUpdate({ accountName: newVal })}
/>
...
In propTypes, nested objects are invalid unless they're PropTypes.shapes. I assume nested objects in Flow types are valid for Flow.
If so, this sounds like a bug.
I am also experiencing this.
To get around if for the moment I have added the following to my .eslintrc:
"react/prop-types": ["error", { "ignore": ["my_prop_key_that_uses_object_map"]}],
Any update about this?
Any updates? I still got this issue
nope, it's still got the "help wanted" label, so it still needs a PR.
Most helpful comment
In propTypes, nested objects are invalid unless they're
PropTypes.shapes. I assume nested objects in Flow types are valid for Flow.If so, this sounds like a bug.