loading...

re: propTypes use in react and some ways to avoid 😫🔧 Errors VIEW POST

TOP OF THREAD FULL DISCUSSION
re: hey, that issue mentioned on github is actually due to the way that the proptypes are added to the component, it's not an issue with the import. t...
 

Really nice to help people out here with the post :), but just to avoid confusion here, Scott is correct.

The article states the problem is with

import propTypes from 'prop-types';

This is not the case. the problem was simply React components expose a property propTypes, not PropTypes. For example, one could still write:

import PropTypes from 'prop-types';
...
MyComponent.propTypes ={
 mySuperProp: PropTypes.string.isRequired.
}

That part doesn't matter as you can declare whatever variable name you wish here.

Code of Conduct Report abuse