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

Ability to verify a prop is a React.Fragment #273

Closed
slorber opened this issue May 13, 2019 · 4 comments
Closed

Ability to verify a prop is a React.Fragment #273

slorber opened this issue May 13, 2019 · 4 comments

Comments

@slorber
Copy link

slorber commented May 13, 2019

@ljharb suggested here to open a new issue to verify react fragment proptypes: #211 (comment)

Just to give more context, for react-intl FormattedMessage component, I'd like to submit a PR to add support for fragments.

Currently the lib has tagName: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),

I want to submit a PR to update to something like tagName: PropTypes.oneOfType([PropTypes.string, PropTypes.element, React.Fragment]),

The lib is able to support fragments at runtime. I'm already using tagName=Fragment. I just want a solution to remove the propTypes warning I have when using Fragments.

I've noticed it works with elementType but I guess my PR wouldn't be accepted by react-intl team as it's a bit too "wide" and less specific

@kuehlein
Copy link

I'm currently using PropTypes.symbol as a work around to suppress the error. I'm not sure if that is specific enough to avoid any possible edge cases though.

@ljharb
Copy link
Collaborator

ljharb commented Aug 12, 2019

@slorber PropTypes.oneOfType([PropTypes.string, PropTypes.element, PropTypes.oneOf([React.Fragment])) should do it, no?

@slorber
Copy link
Author

slorber commented Aug 13, 2019

Hmmm maybe, didn't try that one ;)

Using TS now so not really using proptypes anymore

@ljharb
Copy link
Collaborator

ljharb commented Aug 13, 2019

TS isn’t a replacement for PropTypes; it can check number but not integer; it doesn’t have negated types yet; it can’t do ranges, or many other things. I’d strongly suggest using both.

However. I’ll close this, if you no longer have the feature request.

@ljharb ljharb closed this as completed Aug 13, 2019
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

3 participants