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

PropTypes.oneOf warning does not include expected types #1919

Closed
jgebhardt opened this issue Jul 24, 2014 · 10 comments
Closed

PropTypes.oneOf warning does not include expected types #1919

jgebhardt opened this issue Jul 24, 2014 · 10 comments

Comments

@jgebhardt
Copy link
Contributor

PropType warnings for oneOf say null instead of the actual expected type.

For example, for this PropType:

  name: React.PropTypes.oneOf([
      React.PropTypes.number,
      React.PropTypes.component
   ])

I get the following warning:

Warning: Invalid prop `name` of value `World` supplied to `Hello`, expected
one of [null,null].

Example: http://jsfiddle.net/jxg/N76tr/

React v.0.11.0

@sophiebits
Copy link
Collaborator

You wanted oneOfType. :) We can probably make the message better though…

@jgebhardt
Copy link
Contributor Author

👍

@mdarens
Copy link

mdarens commented Jul 6, 2015

Perhaps createEnumTypeChecker needs to give a warning suggesting using oneOfType if it finds any non-strings in expectedValues?

@jimfb
Copy link
Contributor

jimfb commented Jul 6, 2015

Fixing this warning message. We're drifting away from proptypes and toward flow anyway, but if someone is looking for an easy PR, improving this error message would be a good one.

mdarens added a commit to mdarens/react that referenced this issue Jul 8, 2015
shuaibiyy added a commit to shuaibiyy/react that referenced this issue Nov 30, 2015
@FLGMwt
Copy link

FLGMwt commented May 1, 2016

Might take a look at this. Thoughts:

We probably only want to show a suggestion if check fails and all expectedValues are functions, right? Is that an alright condition for showing the message?

Would it be valuable to also attempt something like checking if each of expectedValues name property === "bound checkType" (which looks like what the unminified PropTypes functions are)?

@reznord
Copy link
Contributor

reznord commented Oct 23, 2016

Hi there !!, I would like to work on this bug. @spicyj @jgebhardt can anyone point me in right direction for working on this bug?

@pinakdas163
Copy link

@spicyj Hi. Is this bug still need to get fixed? I can work on it then. I want to contribute to the development of React project anyway possible.

@nickspeal
Copy link

I just made the same silly mistake and was confused by the error message. Spicyj's comment pointed me to the solution though!

@aweary
Copy link
Contributor

aweary commented Apr 9, 2017

PropTypes have been removed from React core and now exist as a separate package prop-types. Any future feature requests, bug reports, or changes should be directed to the new repo at https://github.com/reactjs/prop-types.

@aweary
Copy link
Contributor

aweary commented Apr 9, 2017

I've opened a new issue over at facebook/prop-types#9 for anyone looking to continue the discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants