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

Change label prop to support PropTypes.node #121

Closed
labkey-nicka opened this issue Jan 11, 2018 · 3 comments
Closed

Change label prop to support PropTypes.node #121

labkey-nicka opened this issue Jan 11, 2018 · 3 comments

Comments

@labkey-nicka
Copy link

Hi,

We recently migrated from 0.11.0 to 1.0.0-beta.2 and are now seeing the following warning from React (16.2.0):

Warning: Failed prop type: Invalid prop `label` of type `object` supplied to `Textarea`, expected `string`.
    in Textarea (created by withFRC(Textarea))
    in withFRC(Textarea) (created by Formsy(withFRC(Textarea)))
    ...

It looks like this is due to a discrepancy between ComponentCommon.propTypes.label which is set to PropTypes.string and Label.PropTypes.label which is set to PropTypes.node.

We use the PropTypes.node variety (hence the warning). Since Label is where it is actually implemented I recommend that ComponentCommon be switched:

ComponentCommon.propTypes = {
    //...
    label: PropTypes.oneOfType({
        PropTypes.string,
        PropTypes.node
        // and maybe PropTypes.object?
    })
}

Here is an example of our usage:

<Textarea label={<LabelOverlay foo={bar}/>} ... />

Thanks!

@twisty
Copy link
Owner

twisty commented Jan 11, 2018

Good catch. 🎣👍

I think just PropTypes.node should do it (because PropTypes.string is encompassed in PropTypes.node as a "thing" that can be rendered?)

ComponentCommon.propTypes = {
    //...
    label: PropTypes.node
}

I'll try and make a new release tomorrow.

@twisty twisty closed this as completed in 0f10e0b Jan 12, 2018
@labkey-nicka
Copy link
Author

Thank you for the fix. I think there may be one other place this needs to be adjusted which is in ComponentHOC.propTypes.label. If you'd prefer I can open a new issue for this HOC variant.

@twisty
Copy link
Owner

twisty commented Mar 5, 2018

Okay, noted! (Reopening, so no need to open a new issue.)

@twisty twisty reopened this Mar 5, 2018
@twisty twisty closed this as completed in 0533bad Mar 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants