Closed slorber closed 5 years ago
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.
@slorber PropTypes.oneOfType([PropTypes.string, PropTypes.element, PropTypes.oneOf([React.Fragment]))
should do it, no?
Hmmm maybe, didn't try that one ;)
Using TS now so not really using proptypes anymore
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 suggested here to open a new issue to verify react fragment proptypes: https://github.com/facebook/prop-types/pull/211#issuecomment-491341623
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