-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Re-add the warning about PropTypes #8080
Comments
particularly because the functions will throw in production |
Out of curiosity, why will they throw errors in 16.0? |
Because we will eliminate all that code in production. It doesn't seem to make sense to ship real code for PropTypes validators if it's normally never used in prod. Therefore we'll replace them all with an empty function. To make this behavior clear we'll make it throw so people don't rely on them for validating e.g. user input. |
You could also create PropTypes on demand, for example Object.defineProperties(api, {'PropTypes': {
// only construct PropTypes when used
get: function () {
return (
Object.defineProperty(
this,
'PropTypes',
{ value: generatePropTypes() }
),
this.PropTypes
);
},
configurable: true,
enumerable: true
.... |
That would defeat the point by including even more code, rather than making the production bundle smaller. |
…k#7132)"" This reverts commit be71f76. In other words, now we again have the warning if you attempt to call PropTypes manually. It was removed in facebook#8066 but we shouldn't have done this since we still want to avoid people accidentally calling them in production (and even more so since now it would throw). Fixes facebook#8080.
…k#7132)"" This reverts commit be71f76. In other words, now we again have the warning if you attempt to call PropTypes manually. It was removed in facebook#8066 but we shouldn't have done this since we still want to avoid people accidentally calling them in production (and even more so since now it would throw). Fixes facebook#8080.
* Revert "Revert "Warn if PropType function is called manually (#7132)"" This reverts commit be71f76. In other words, now we again have the warning if you attempt to call PropTypes manually. It was removed in #8066 but we shouldn't have done this since we still want to avoid people accidentally calling them in production (and even more so since now it would throw). Fixes #8080. * Pass secret in ReactControlledValuePropTypes * Record tests
After a discussion with @spicyj we decided to keep the warning even though the functions will throw in production. The warning is the only way to learn about that.
We should also document how to pass the secret through in case you know what you're doing.
The text was updated successfully, but these errors were encountered: