T
24

PSA: My first React project crashed because I ignored PropTypes entirely

Spent a whole weekend building a dashboard in React for a local nonprofit in Austin. Everything worked fine in my dev environment, but when I pushed it live, the whole thing broke because I passed a number where it expected an array. I spent 6 hours tracking it down. Looking back, PropTypes would have caught that in 5 seconds flat. Anyone else skip the basic validation and regret it later?
2 comments

Log in to join the discussion

Log In
2 Comments
elliot_harris25
My buddy Jesse built a whole e-commerce site for a friend's candle shop last year. He was using a component that displayed product ratings, and he assumed the API would always send back an array of star objects. Well, the API sent back a null value for a new product that had no reviews yet. The whole product page just went blank. He was refreshing and clearing cache for like two hours before he finally saw the console error pointing right at the prop type mismatch. PropTypes would have caught that null vs array issue immediately, but he skipped it because he thought the API was "simple enough.
7
fiona_nelson51
Did your buddy eventually add PropTypes after that, or is he still living dangerously?
-1