DEV Community

Discussion on: propTypes use in react and some ways to avoid 😫🔧 Errors

Collapse
 
kylessg profile image
Kyle Johnson • Edited

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.