Skip to content

Conversation

@alansouzati
Copy link
Contributor

I had people on my team sending wrong arguments to oneOf and oneOfType attributes from PropTypes.

The current message exposed some internal attributes to the user with the following message:

Warning: Failed propType: checker is not a function Check the render method of Chart.

This warning is a little misleading, I had to spend some time trying to figure out who was invoking this checker function, unsuccessfully. Then, after some time, I realized the argument to oneOf and oneOfType was actually invalid and it had nothing to do with checker function.

I've opened a StackOverflow case for this.

This pull request aims to fix this problem by validating the argument type as an array in both createUnionTypeChecker and createEnumTypeChecker. I've added the corresponding tests for this.

Alan

@zpao
Copy link
Member

zpao commented May 26, 2015

For anybody following along at home, this is a re-submit of #3807.

Sorry you had issues rebasing, but I appreciate the work, thanks!

zpao added a commit that referenced this pull request May 26, 2015
Adding validation for array in ReactPropTypes.
@zpao zpao merged commit 1503994 into facebook:master May 26, 2015
@alansouzati
Copy link
Contributor Author

Thanks @zpao, I apologize for the back-and-forth on this PR. At least, now I've learned how to properly do it.

sophiebits added a commit to sophiebits/react that referenced this pull request May 27, 2015
Follow-up to facebook#3963. (Returning an Error wasn't useful; it just caused a later error when actually using it because type checkers need to be functions.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants