4 ms·
Not necessarily - you could be parsing a JSON API response or something.
by untog 10y ago
Not necessarily - you could be parsing a JSON API response or something.
- raquo 10y agoIf you don't trust your JSON input to be of proper type, you should validate its type immediately when you receive it, before you start fanning it out to your code. Spreading this work to prop types just makes it harder to keep track of it, and harder to find the source of the problem. Besides, some of that broken JSON data might never even be passed through proptypes (e.g. if that data lives only in a component's state). Also, there are compile-time solutions to this in some compile-to-JS languages, e.g. like https://github.com/lihaoyi/autowire https://github.com/lihaoyi/autowire for Scala.js