Skip to content Skip to sidebar Skip to footer

Proptypes Doesn't Work In React

I am running React 16.2.0 and I am using PropTypes 15.6.1. I am using ES6 syntax and Webpack. I am trying to make PropTypes throw a warning when I pass invalid props, but it doesn'

Solution 1:

Working as expected :

Warning: Failed prop type: Invalid prop message of type string supplied to SimpleMessage, expected function.

Be sure to check your browser console, this is where errors are displayed.

https://codepen.io/anon/pen/paGYjm?editors=1111


Also :

You shouldn’t apply UglifyJsPlugin or DefinePlugin with 'production' value in development because they will hide useful React warnings, and make the builds much slower.

source

Solution 2:

That's because you've defined propType as function, but you're sending it as a string.

Change the code to message: PropTypes.string

Post a Comment for "Proptypes Doesn't Work In React"