You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, this package will throw an error when validator functions are called directly in both dev and production mode. Calling validator functions directly was previously supported when PropTypes was bundled with React in < react@15.4, so it's understandable that you want to warn developers who are changing to the prop-types package. However, it's been well over a year since directly calling validator functions was deprecated, so the utility of the error message is now considerably less.
My question is: Isn't it enough to warn developers only in dev mode?
By removing the error message from production mode, you could save around 160 bytes gzipped from the final production bundle. That's a paltry number, but since prop-types is bundled in basically every react app in existence it does add up.
The text was updated successfully, but these errors were encountered:
What I tried to get across in my original comment was that by removing the error from prod mode we could save 160 bytes from basically every React site in existence which would be great. I guess I don’t get why throwing this error in production is any better than just returning undefined as is done when the package is used correctly. As I understand it, the message is only useful for a hypothetical project that
only uses production mode when developing,
decided to switch to the prop-types package, but did not realize that this behavior changed,
has code that relies on prop-types throwing in production when incorrect props are passed and
would not easily discover that said code didn’t work anymore.
Maybe I misunderstood something, but to me this error seems pretty useless. Removing it would technically be a breaking change though so not something you would want to do unless there is ever a 16.0 release.
Currently, this package will throw an error when validator functions are called directly in both dev and production mode. Calling validator functions directly was previously supported when PropTypes was bundled with React in < react@15.4, so it's understandable that you want to warn developers who are changing to the prop-types package. However, it's been well over a year since directly calling validator functions was deprecated, so the utility of the error message is now considerably less.
My question is: Isn't it enough to warn developers only in dev mode?
By removing the error message from production mode, you could save around 160 bytes gzipped from the final production bundle. That's a paltry number, but since prop-types is bundled in basically every react app in existence it does add up.
The text was updated successfully, but these errors were encountered: