facebook / prop-types

Runtime type checking for React props and similar objects
MIT License
4.48k stars 356 forks source link

Using prop-types in production #280

Closed Brianzchen closed 5 years ago

Brianzchen commented 5 years ago

Hi there, I have a use case where I want to use prop-types to validate that json data coming from the backend api is passing into my component properly, this helps me to highlight bugs and inconsistencies between the api and what I expect in the front-end early.

But as I can see, prop-types is completely shimmed when node env is set to production. This works for me during development with test environments, but not when I push the code into my built test environment and want to monitor irregularities.

I want to understand if the reason for this is that it can cause a major performance impact otherwise? Or if not, is there a possibility the propTypes.checkPropTypes can be enhanced with a param to run in production on a case by case basis?

Or if not maybe there's another library that already does what I'm describing and I'm not aware of it 🤔

Thanks!

ljharb commented 5 years ago

See “If you DO want to use validation in production” in the readme.