-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
explicitNull
does not work when part of PropTypes.oneOfType
#12
Comments
I would expect Similarly, I think I'm not sure this can be fixed; what happens if instead of |
|
I think we would have to explicitly iterate through each of the validators, make sure one passes and go from there. |
Interesting, OK - seems like this is a quirk of |
@ljharb any idea why a PropType like this wouldn't work? const attemptOne = or([node.isRequired, explicitNull().isRequired]).isRequired;
const attemptTwo = or([node, explicitNull().isRequired]).isRequired; The tests you included cover those cases, and I assume they pass since no one has mentioned this in 4 years, but still we see:
Any idea what we might be doing wrong here? I know |
@slapbox what version of react are you using? make sure |
Wow what a response time! Thank you for your reply @ljharb!
Our React version is Unfortunately I can't share the code of The parent of const [referenceElement, setPopperReferenceElement] = React.useState(null);
<InnerPopper
referenceElement={referenceElement}
/> I'm not sure what I can share that might be useful, but I never see the value set to anything other than |
Note that airbnb-prop-types doesn't support React 17 yet (see #73) but i doubt that's the issue here. Given that our tests pass, I'm pretty confused what the issue would be, and I'm not sure how to figure it out. The "expected an array" is strange - what's |
Ah I didn't realize that React 17 wasn't officially supported, thanks for the tip! Really hate to waste your time, because of course the issue was on our end! Sorry @ljharb, but a big thanks for all you do! TLDR: Not a problem with Additionally, In case it helps someone in the future, we are now using: or([instanceOf(Element), explicitNull().isRequired]) |
|
Things that work as expected:
foo: explicitNull().isRequired
breaks for anything that is notfoo={null}
, includingfoo={undefined}
.foo: PropTypes.oneOfType([explicitNull()]).isRequired
breaks onfoo="foo"
foo: PropTypes.oneOfType([explicitNull().isRequired])
breaks onfoo="foo"
Things that do not work as expected:
foo: PropTypes.oneOfType([explicitNull()]).isRequired
breaks onfoo={null}
foo: PropTypes.oneOfType([explicitNull().isRequired])
passes onfoo={undefined}
The text was updated successfully, but these errors were encountered: