You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 1, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 1, 2024. It is now read-only.
oneOfType() does not seem to allow all types specified #388
I am running into an issue where oneOfType() is passed in types of shape and string but is only allowing string seemingly.
Reproduced here (using a simplified version of types I have encountered on a project I am working on), https://jsfiddle.net/liamness/1du5jvwt/, with the warning:
Failed prop type: Invalid prop `schema[1]` supplied to `ComponentName`, expected one of type [string].
The real issue is being masked here; it's that name: PropTypes.string.required, is invalid. It's .isRequired, not .required.
When I fix that, I correctly see no error.
I see the proper error message when I use just the shape - iow, oneOfType seems to be suppressing the actually helpful error message from shape, so that seems like a bug worth fixing.
Activity
ljharb commentedon Oct 20, 2022
The real issue is being masked here; it's that
name: PropTypes.string.required,is invalid. It's.isRequired, not.required.When I fix that, I correctly see no error.
I see the proper error message when I use just the shape - iow,
oneOfTypeseems to be suppressing the actually helpful error message fromshape, so that seems like a bug worth fixing.liamness commentedon Oct 20, 2022
You're right, that fixes the issue. I imagine what's happening is that incorrect arguments to
oneOfTypeare being disregarded. Thanks!