Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'(react/prop-types): Missing in props validation' when props contain a flow 'map' object #1280

Open
JonathonAshworth opened this issue Jun 30, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@JonathonAshworth
Copy link

commented Jun 30, 2017

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 })}
            />
    ...
@ljharb

This comment has been minimized.

Copy link
Collaborator

commented Jun 30, 2017

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.

@ljharb ljharb added bug flow labels Jun 30, 2017

@dominicfraser

This comment has been minimized.

Copy link

commented Nov 3, 2018

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"]}],
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.