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

Fix Symbol to String conversion in ReactPropTypes.oneOf #9202

Closed
wants to merge 2 commits into from
Closed

Fix Symbol to String conversion in ReactPropTypes.oneOf #9202

wants to merge 2 commits into from

Conversation

ooflorent
Copy link

This PR addresses issues when using symbols in PropTypes.oneOf (#9181).

  1. The safe way to convert a Symbol into a String is to use String(sym) or sym.toString(). Using template string interpolation (ES6) or concatenation (ES5/Babel) throws a TypeError.

  2. The current warning does not include symbols (because JSON.stringify strips them). A replacer is added to handle them. This is done in the second commit (so it can be easily reverted).

The safe way to convert a `Symbol` into a `String` is to use `String(sym)` or
`sym.toString()`. Using template string interpolation (ES6) or concatenation (ES5/Babel)
throws a `TypeError`.

Closes #9181
@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.

Sorry about that @ooflorent!

@aweary aweary closed this Apr 9, 2017
@aweary
Copy link
Contributor

aweary commented Apr 9, 2017

@ooflorent I've opened a new issue for this at facebook/prop-types#10 if you want to continue working on this.

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.

None yet

3 participants