Accessing PropTypes via the main React package is deprecated

As others have mentioned- if you have audited your own project for PropTypes uses but you’re still seeing the warning- it’s likely coming from an upstream dependency. One way you can track down the cause of this warning is by setting a debug breakpoint where it’s logged and then stepping back to the caller. Here’s … Read more

How to test React PropTypes through Jest?

The underlying problem is How to test console.log? The short answer is that you should replace the console.{method} for the duration of the test. The common approach is to use spies. In this particular case, you might want to use stubs to prevent the output. Here is an example implementation using Sinon.js (Sinon.js provides standalone … Read more

Using forwardRef with proptypes and eslint

You are almost done with your third attempt. But you don’t have to use twice forwardRef, the first use with the Button declaration is enough. The display name rule is not an error (neither at JavaScript nor React level), but rather an intentional prop in order to show the “real” name of the component, used … Read more

react: why static propTypes

static was not part of the last generation of Javascript (“ES5”), which is why you won’t find it in older documentation. However it, and the rest of the “ES6” class syntax is now supported in all major browsers except Internet Explorer (http://caniuse.com/#search=es6), and if you use a transpiler like Babel you can use it in … Read more

React: PropTypes in stateless functional component

You should change the casing on the property to propTypes: – List.PropTypes = { + List.propTypes = { todos: PropTypes.array.isRequired, }; Correct: List.propTypes = { todos: PropTypes.array.isRequired, }; (The instance of a PropTypes object is lowercase, but the Class/Type is uppercase. The instance is List.propTypes. The Class/Type is PropTypes.)

React propTypes: objectOf vs shape?

PropTypes.objectOf is used when describing an object whose properties are all the same type. const objectOfProp = { latitude: 37.331706, longitude: -122.030783 } // PropTypes.objectOf(PropTypes.number) PropTypes.shape is used when describing an object whose keys are known ahead of time, and may represent different types. const shapeProp = { name: ‘Jane’, age: 25 } // PropTypes.shape({ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)